Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <bitset>
- #include <cassert>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <list>
- #include <map>
- #include <queue>
- #include <set>
- #include <string>
- #include <sstream>
- #include <vector>
- #include <complex>
- #include <ctime>
- #include <stack>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef vector<int> VI;
- typedef vector< VI > VVI;
- typedef pair<int, int> PII;
- typedef vector<PII> VPII;
- #define REP(i, n) for(int i = 0; i < (n); ++i)
- #define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
- #define FOR(i, x, y) for(int i = (x); i <= (y); ++i)
- #define RFOR(i, x, y) for(int i = (x); i >= (y); --i)
- #define SZ(a) (int)(a).size()
- #define ALL(a) (a).begin(),(a).end()
- #define SORT(a) sort(ALL(a))
- #define CLEAR(x) memset(x, 0, sizeof x);
- #define COPY(FROM, TO) memcpy(TO, FROM, sizeof TO);
- #define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
- #define pb push_back
- #define mk make_pair
- #define sqr(x) ((x)*(x))
- #define X first
- #define Y second
- const long double pi=acos(-1.0);
- const double EPS = 1E-9;
- const int inf = (1e+9);
- const int NMAX = 31625;
- const int MOD = 1743;
- int r1, c1, r2, c2;
- int m[8][8];
- int cc = 0, ans = 0;
- int main () {
- cin >> r1 >> c1 >> r2 >> c2;
- REP (i, 8) {
- REP (j, 8) {
- if (i % 2 == 0) {
- if (j % 2 == 1)
- m[i][j] = 1;
- } else {
- if (j % 2 == 0)
- m[i][j] = 1;
- }
- }
- }
- if (r1 == r2 || c1 == c2)
- cout << "1 ";
- else
- cout << "2 ";
- if (m[r1][c1] != m[r2][c2]) {
- cout << "0 ";
- } else {
- int i = 0, j = 0;
- bool f = 0;
- while (1) {
- if (r1 + i > 8 || c1 + j > 8)
- break;
- if (r1 + i == r2 && c1 + j == c2)
- f = 1;
- i++, j++;
- }
- i = 0, j = 0;
- while (1) {
- if (r1 + i <= 0 || c1 + j <= 0)
- break;
- if (r1 + i == r2 && c1 + j == c2)
- f = 1;
- i--, j--;
- }
- i = 0, j = 0;
- while (1) {
- if (r1 + i > 8 || c1 + j <= 0)
- break;
- if (r1 + i == r2 && c1 + j == c2)
- f = 1;
- i++, j--;
- }
- i = 0, j = 0;
- while (1) {
- if (r1 + i <= 0 || c1 + j > 8)
- break;
- if (r1 + i == r2 && c1 + j == c2)
- f = 1;
- i--, j++;
- }
- if (f)
- cout << "1 ";
- else cout << "2 ";
- }
- int i = 0, j = 0, cc = 0;
- bool f = 0;
- while (1) {
- if (r1 + i > 8 || c1 + j > 8)
- break;
- if (r1 + i == r2) {
- cc += abs(c1 + j - c2); f = 1;
- } else if (c1 + j == c2) {
- cc += abs(r1 + i - r2); f = 1;
- }
- i++, j++;
- cc++;
- }
- if (f) ans = max (ans, cc - 1);
- i = 0, j = 0, cc = 0;
- while (1) {
- if (r1 + i <= 0 || c1 + j <= 0)
- break;
- if (r1 + i == r2) {
- cc += abs(c1 + j - c2); f = 1;
- } else if (c1 + j == c2) {
- cc += abs(r1 + i - r2); f = 1;
- }
- i--, j--;
- cc++;
- }
- if (f) ans = max (ans, cc - 1);
- i = 0, j = 0, cc = 0;
- while (1) {
- if (r1 + i > 8 || c1 + j <= 0)
- break;
- if (r1 + i == r2) {
- cc += abs(c1 + j - c2); f = 1;
- } else if (c1 + j == c2) {
- cc += abs(r1 + i - r2); f = 1;
- }
- i++, j--;
- cc++;
- }
- if (f) ans = max (ans, cc - 1);
- i = 0, j = 0, cc = 0;
- while (1) {
- if (r1 + i <= 0 || c1 + j > 8)
- break;
- if (r1 + i == r2) {
- cc += abs(c1 + j - c2); f = 1;
- } else if (c1 + j == c2) {
- cc += abs(r1 + i - r2); f = 1;
- }
- i--, j++;
- cc++;
- }
- if (f) ans = max (ans, cc - 1);
- cout << ans;
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment