This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
using namespace std;
int sum[100007][3];
main(){
#ifdef LOCAL
freopen("N_input.txt", "r", stdin);
//freopen("N_output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int ans = 0;
for (int i = 0; i < 2*n; ++i) {
int x, y;
cin >> x >> y;
int z, t;
if (x <= 0) z = 1;
else if (x > n) z = n;
else z = x;
if (y <= 1) t = 1;
else t = 2;
ans += abs(x-z) + abs(y-t);
sum[z][t]++;
}
int bal = 0;
for (int i = 0; i <= n; ++i) {
for (int y = 0; y < 2; ++y) {
int x = i-y;
if (x < 0 || x >= n) continue;
bal += sum[x+1][y+1] - 1;
}
ans += abs(bal);
}
cout << ans;
}
Compilation message (stderr)
joi2019_ho_t4.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |