Skip to content

Commit 257443b

Browse files
authored
Merge pull request #508 from xirc/atcoder/abc184
AtCoder/ABC184C
2 parents 068f285 + cd1f72a commit 257443b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

atcoder/abc184/C/main.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int solve(ll a, ll b, ll c, ll d) {
8+
if (a == c && b == d) return 0;
9+
//
10+
if (a + b == c + d) return 1;
11+
if (a - b == c - d) return 1;
12+
if (abs(a-c) + abs(b - d) <= 3) return 1;
13+
//
14+
if ((a + b) % 2 == (c + d) % 2) return 2;
15+
if (abs(a-c) + abs(b -d) <= 6) return 2;
16+
if (abs((a + b) - (c + d)) <= 3) return 2;
17+
if (abs((a - b) - (c - d)) <= 3) return 2;
18+
19+
return 3;
20+
21+
}
22+
23+
int main() {
24+
ios_base::sync_with_stdio(false);
25+
cin.tie(0); cout.tie(0);
26+
27+
int r1, c1, r2, c2;
28+
cin >> r1 >> c1 >> r2 >> c2;
29+
cout << solve(r1, c1, r2, c2) << endl;
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)