Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- ios::sync_with_stdio(0);
- int x[3], y[3];
- cin >> x[0] >> y[0];
- cin >> x[1] >> y[1];
- cin >> x[2] >> y[2];
- sort(x, x + 3);
- sort(y, y + 3);
- int ans = 1e9;
- for (int i = 1; i <= 2021; i++) {
- int ret = 0;
- ret += abs(i - x[0]);
- ret += abs(i - x[1]);
- ret += abs(i - x[2]);
- if (y[0] == y[2]) {
- ret += 2;
- } else if (y[0] == y[1] || y[1] == y[2]) {
- ret++;
- }
- ans = min(ans, ret);
- }
- for (int i = 1; i <= 2021; i++) {
- int ret = 0;
- ret += abs(i - y[0]);
- ret += abs(i - y[1]);
- ret += abs(i - y[2]);
- if (x[0] == x[2]) {
- ret += 2;
- } else if (x[0] == x[1] || x[1] == x[2]) {
- ret++;
- }
- ans = min(ans, ret);
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement