Advertisement
aka007

yandex

May 16th, 2014
2,934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. /*******************
  2. Akash Agrawall
  3. IIIT HYDERABAD
  4. ***********************/
  5.  
  6.  
  7. #include<cstdio>
  8. #include<iostream>
  9. #include<cstdlib>
  10. #include<cmath>
  11. #include<cstring>
  12. #include<climits>
  13. #include<algorithm>
  14. #include<vector>
  15. #include<set>
  16. #include<map>
  17. #include<bitset>
  18. #include<stack>
  19. #include<queue>
  20. #include<stdio.h>
  21. #include<string.h>
  22. #include<math.h>
  23. #include<functional>
  24. #include<numeric>
  25. using namespace std;
  26. #define ll long long int
  27. #define FOR(i,a,b) for(i= (int )a ; i < (int )b ; ++i)
  28. #define rep(i,n) FOR(i,0,n)
  29. #define INF INT_MAX
  30. #define ALL(x) x.begin(),x.end()
  31. #define LET(x,a) __typeof(a) x(a)
  32. #define IFOR(i,a,b) for(LET(i,a);i!=(b);++i)
  33. #define EACH(it,v) IFOR(it,v.begin(),v.end())
  34. #define pb push_back
  35. #define sz(x) int(x.size())
  36. #define mp make_pair
  37. #define fill(x,v) memset(x,v,sizeof(x))
  38. #define max(a,b) ((a)>(b)?(a):(b))
  39. #define min(a,b) ((a)<(b)?(a):(b))
  40. #define pi(n) printf("%d ",n)
  41. #define pd(n) printf("%lf ",n)
  42. #define pdl(n) printf("%lf\n",n)
  43. #define pin(n) printf("%d\n",n)
  44. #define pl(n) printf("%lld",n)
  45. #define pln(n) printf("%lld\n",n)
  46. #define si(n) scanf("%d",&n)
  47. #define sl(n) scanf("%lld",&n)
  48. #define sd(n) scanf("%lf",&n)
  49. #define ss(n) scanf("%s",n)
  50. #define scan(v,n) vector<int> v;rep(i,n){ int j;si(j);v.pb(j);}
  51. #define mod (int)(1e9 + 7)
  52. int rook(int wk1,int wk2,int wr1, int wr2, int bk1,int bk2)
  53. {
  54. if((wr1==bk1 && !(wk1==wr1 && ((wk2>=wr2 && wk2<=bk2) || (wk2<=wr2 && wk2>=bk2)))) || (wr2==bk2 && !(wk2==wr2 && ((wk1>=wr1 && wk1<=bk1) || (wk1<=wr1 && wk1>=bk1)))))
  55. return 1;
  56. return 0;
  57. }
  58. int attack(int wk1,int wk2,int wr1,int wr2,int bk1,int bk2)
  59. {
  60. int flag=0;
  61. if(bk1==wr1 && bk2==wr2)
  62. flag=1;
  63. if((wk1+1==bk1 && wk2==bk2) || (wk1-1==bk1 && wk2==bk2) || (wk1==bk1 && wk2+1==bk2) || (wk1==bk1 && wk2-1==bk2) || (wk1+1==bk1 && wk2+1==bk2) || (wk1-1==bk1 && wk2-1==bk2) || (wk1+1==bk1 && wk2-1==bk2) || (wk1-1==bk1 && wk2+1==bk2) || (rook(wk1,wk2,wr1,wr2,bk1,bk2) && !flag))
  64. return 1;
  65. return 0;
  66. }
  67. int main()
  68. {
  69. char ch,ch1;
  70. int wk1,wk2,wr1,wr2,bk1,bk2,cnt=0;
  71. ch=getchar();
  72. ch1=getchar();
  73. wk1=ch-'a';
  74. wk2=ch1-'0';
  75. ch=getchar();
  76. ch=getchar();
  77. ch1=getchar();
  78. wr1=ch-'a';
  79. wr2=ch1-'0';
  80. ch=getchar();
  81. ch=getchar();
  82. ch1=getchar();
  83. bk1=ch-'a';
  84. bk2=ch1-'0';
  85. ch=getchar();
  86. wk2--;
  87. wr2--;
  88. bk2--;
  89. if(attack(wk1,wk2,wr1,wr2,bk1,bk2) && (attack(wk1,wk2,wr1,wr2,bk1+1,bk2) && attack(wk1,wk2,wr1,wr2,bk1,bk2+1) && attack(wk1,wk2,wr1,wr2,bk1+1,bk2+1) && attack(wk1,wk2,wr1,wr2,bk1+1,bk2-1) && attack(wk1,wk2,wr1,wr2,bk1-1,bk2+1) && attack(wk1,wk2,wr1,wr2,bk1-1,bk2-1) && attack(wk1,wk2,wr1,wr2,bk1,bk2-1) && attack(wk1,wk2,wr1,wr2,bk1-1,bk2)))
  90. {
  91. printf("Checkmate\n");
  92. return 0;
  93. }
  94. if(!(rook(wk1,wk2,wr1,wr2,bk1,bk2)) && ((wk1+1==bk1 && wk2==bk2) || (wk1-1==bk1 && wk2==bk2) || (wk1==bk1 && wk2+1==bk2) || (wk1==bk1 && wk2-1==bk2) || (wk1+1==bk1 && wk2+1==bk2) || (wk1-1==bk1 && wk2-1==bk2) || (wk1+1==bk1 && wk2-1==bk2) || (wk1-1==bk1 && wk2+1==bk2)))
  95. {
  96. printf("Strange\n");
  97. return 0;
  98. }
  99. if(attack(wk1,wk2,wr1,wr2,bk1,bk2))
  100. {
  101. printf("Check\n");
  102. return 0;
  103. }
  104. if((attack(wk1,wk2,wr1,wr2,bk1+1,bk2) && attack(wk1,wk2,wr1,wr2,bk1,bk2+1) && attack(wk1,wk2,wr1,wr2,bk1+1,bk2+1) && attack(wk1,wk2,wr1,wr2,bk1+1,bk2-1) && attack(wk1,wk2,wr1,wr2,bk1-1,bk2+1) && attack(wk1,wk2,wr1,wr2,bk1-1,bk2-1) && attack(wk1,wk2,wr1,wr2,bk1-1,bk2+1) && attack(wk1,wk2,wr1,wr2,bk1-1,bk2)))
  105. {
  106. printf("Stalemate\n");
  107. return 0;
  108. }
  109. printf("Normal\n");
  110. return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement