prestige

Untitled

Dec 9th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. #include <algorithm>
  2. #include <bitset>
  3. #include <cassert>
  4. #include <cmath>
  5. #include <cstdio>
  6. #include <cstdlib>
  7. #include <cstring>
  8. #include <iostream>
  9. #include <list>
  10. #include <map>
  11. #include <queue>
  12. #include <set>
  13. #include <string>
  14. #include <sstream>
  15. #include <vector>
  16. #include <complex>
  17. #include <ctime>
  18. #include <stack>
  19.  
  20. using namespace std;
  21.  
  22. typedef long long ll;
  23. typedef unsigned long long ull;
  24. typedef vector<int> VI;
  25. typedef vector< VI > VVI;
  26. typedef pair<int, int> PII;
  27. typedef vector<PII> VPII;
  28.  
  29. #define REP(i, n) for(int i = 0; i < (n); ++i)
  30. #define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
  31. #define FOR(i, x, y) for(int i = (x); i <= (y); ++i)
  32. #define RFOR(i, x, y) for(int i = (x); i >= (y); --i)
  33. #define SZ(a) (int)(a).size()
  34. #define ALL(a) (a).begin(),(a).end()
  35. #define SORT(a) sort(ALL(a))
  36. #define CLEAR(x) memset(x, 0, sizeof x);
  37. #define COPY(FROM, TO) memcpy(TO, FROM, sizeof TO);
  38. #define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
  39. #define pb push_back
  40. #define mk make_pair
  41. #define sqr(x) ((x)*(x))
  42. #define X first
  43. #define Y second
  44. const long double pi=acos(-1.0);
  45. const double EPS = 1E-9;
  46. const int inf = (1e+9);
  47. const int NMAX = 31625;
  48. const int MOD = 1743;
  49.  
  50. int r1, c1, r2, c2;
  51. int m[8][8];
  52. int cc = 0, ans = 0;
  53. int main () {
  54. cin >> r1 >> c1 >> r2 >> c2;
  55. REP (i, 8) {
  56. REP (j, 8) {
  57. if (i % 2 == 0) {
  58. if (j % 2 == 1)
  59. m[i][j] = 1;
  60. } else {
  61. if (j % 2 == 0)
  62. m[i][j] = 1;
  63. }
  64. }
  65. }
  66. if (r1 == r2 || c1 == c2)
  67. cout << "1 ";
  68. else
  69. cout << "2 ";
  70. if (m[r1][c1] != m[r2][c2]) {
  71. cout << "0 ";
  72. } else {
  73. int i = 0, j = 0;
  74. bool f = 0;
  75. while (1) {
  76. if (r1 + i > 8 || c1 + j > 8)
  77. break;
  78. if (r1 + i == r2 && c1 + j == c2)
  79. f = 1;
  80. i++, j++;
  81. }
  82. i = 0, j = 0;
  83. while (1) {
  84. if (r1 + i <= 0 || c1 + j <= 0)
  85. break;
  86. if (r1 + i == r2 && c1 + j == c2)
  87. f = 1;
  88. i--, j--;
  89. }
  90. i = 0, j = 0;
  91. while (1) {
  92. if (r1 + i > 8 || c1 + j <= 0)
  93. break;
  94. if (r1 + i == r2 && c1 + j == c2)
  95. f = 1;
  96. i++, j--;
  97. }
  98. i = 0, j = 0;
  99. while (1) {
  100. if (r1 + i <= 0 || c1 + j > 8)
  101. break;
  102. if (r1 + i == r2 && c1 + j == c2)
  103. f = 1;
  104. i--, j++;
  105. }
  106. if (f)
  107. cout << "1 ";
  108. else cout << "2 ";
  109. }
  110.  
  111.  
  112. int i = 0, j = 0, cc = 0;
  113. bool f = 0;
  114. while (1) {
  115. if (r1 + i > 8 || c1 + j > 8)
  116. break;
  117. if (r1 + i == r2) {
  118. cc += abs(c1 + j - c2); f = 1;
  119. } else if (c1 + j == c2) {
  120. cc += abs(r1 + i - r2); f = 1;
  121. }
  122. i++, j++;
  123. cc++;
  124. }
  125. if (f) ans = max (ans, cc - 1);
  126. i = 0, j = 0, cc = 0;
  127. while (1) {
  128. if (r1 + i <= 0 || c1 + j <= 0)
  129. break;
  130. if (r1 + i == r2) {
  131. cc += abs(c1 + j - c2); f = 1;
  132. } else if (c1 + j == c2) {
  133. cc += abs(r1 + i - r2); f = 1;
  134. }
  135. i--, j--;
  136. cc++;
  137. }
  138. if (f) ans = max (ans, cc - 1);
  139. i = 0, j = 0, cc = 0;
  140. while (1) {
  141. if (r1 + i > 8 || c1 + j <= 0)
  142. break;
  143. if (r1 + i == r2) {
  144. cc += abs(c1 + j - c2); f = 1;
  145. } else if (c1 + j == c2) {
  146. cc += abs(r1 + i - r2); f = 1;
  147. }
  148. i++, j--;
  149. cc++;
  150. }
  151. if (f) ans = max (ans, cc - 1);
  152. i = 0, j = 0, cc = 0;
  153. while (1) {
  154. if (r1 + i <= 0 || c1 + j > 8)
  155. break;
  156. if (r1 + i == r2) {
  157. cc += abs(c1 + j - c2); f = 1;
  158. } else if (c1 + j == c2) {
  159. cc += abs(r1 + i - r2); f = 1;
  160. }
  161. i--, j++;
  162. cc++;
  163. }
  164. if (f) ans = max (ans, cc - 1);
  165. cout << ans;
  166. }
  167. /*
  168.  
  169. */
Advertisement
Add Comment
Please, Sign In to add comment