# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
485870 |
2021-11-09T15:17:37 Z |
rainboy |
ČVENK (COI15_cvenk) |
C |
|
43 ms |
2196 KB |
#include <stdio.h>
#define N 100000
#define X 512
int kk[X][X], n, x_, y_;
int dfs1(int x, int y) {
int k, k1, k2;
if (x >= X || y >= X || (x & y) != 0)
return 0;
k1 = dfs1(x, y + 1), k2 = dfs1(x + 1, y), k = kk[x][y] + k1 + k2;
if (k1 * 2 <= n && k2 * 2 <= n && (n - k) * 2 <= n)
x_ = x, y_ = y;
return k;
}
long long ans;
int dist(int x1, int y1, int x2, int y2) {
int d = 0;
while (x1 != x2 || y1 != y2) {
d++;
if (x1 + y1 > x2 + y2) {
if ((x1 - 1 & y1) == 0)
x1--;
else
y1--;
} else {
if ((x2 - 1 & y2) == 0)
x2--;
else
y2--;
}
}
return d;
}
int main() {
static int xx[N], yy[N];
int i;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d%d", &xx[i], &yy[i]);
kk[xx[i]][yy[i]]++;
}
dfs1(0, 0);
ans = 0;
for (i = 0; i < n; i++)
ans += dist(xx[i], yy[i], x_, y_);
printf("%lld\n", ans);
return 0;
}
Compilation message
cvenk.c: In function 'dist':
cvenk.c:27:12: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
27 | if ((x1 - 1 & y1) == 0)
| ~~~^~~
cvenk.c:32:12: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
32 | if ((x2 - 1 & y2) == 0)
| ~~~^~~
cvenk.c: In function 'main':
cvenk.c:45:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
45 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
cvenk.c:47:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | scanf("%d%d", &xx[i], &yy[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1456 KB |
Output is correct |
2 |
Correct |
43 ms |
2196 KB |
Output is correct |
3 |
Correct |
22 ms |
1860 KB |
Output is correct |
4 |
Correct |
25 ms |
1976 KB |
Output is correct |
5 |
Correct |
37 ms |
1996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |