Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- int n, m, ans;
- int a[4], k, X1, Y1, X2, Y2;
- int main()
- {
- freopen("job.in", "r", stdin);
- freopen("job.out", "w", stdout);
- scanf("%d %d\n", &n, &m);
- int x = 0;
- char c;
- while (scanf("%c", &c) == 1)
- {
- if ('0' <= c && c <= '9')
- x = x * 10 + c - '0';
- else
- {
- if (x)
- {
- a[k++] = x;
- x = 0;
- }
- }
- }
- X1 = a[0];
- Y1 = a[1];
- X2 = a[2];
- Y2 = a[3];
- int dx = X2 - X1;
- int dy = Y2 - Y1;
- if (dx && dy)
- {
- int d = min(abs(dx), abs(dy));
- dx /= abs(dx);
- dy /= abs(dy);
- ans = d * 2;
- X1 += dx * d;
- Y1 += dy * d;
- }
- if (X1 == X2 && Y1 < Y2 && ((X1 + Y1) & 1) == 1) Y1++, ans++;
- if (X1 == X2 && Y2 < Y1 && ((X1 + Y1) & 1) == 1) Y1--, ans++;
- if (Y1 == Y2 && X1 < X2 && ((X1 + Y1) & 1) == 0) X1++, ans++;
- if (Y1 == Y2 && X2 < X1 && ((X1 + Y1) & 1) == 0) X1--, ans++;
- ans += abs(X1 - X2) * 2 + (abs(X1 - X2) & 1);
- ans += abs(Y1 - Y2) * 2 + (abs(Y1 - Y2) & 1);
- printf("%d\n", ans * 200);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement