이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |