# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
917345 |
2024-01-27T22:22:25 Z |
rainboy |
None (KOI17_cut) |
C++17 |
|
2 ms |
8840 KB |
#include <stdio.h>
#define N 1000000
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int ll[N], rr[N], hh[N];
void sort(int *hh, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, h = hh[l + rand_() % (r - l)], tmp;
while (j < k) {
int c = ll[hh[j]] != ll[h] ? ll[hh[j]] - ll[h] : rr[h] - rr[hh[j]];
if (c == 0)
j++;
else if (c < 0) {
tmp = hh[i], hh[i] = hh[j], hh[j] = tmp;
i++, j++;
} else {
k--;
tmp = hh[j], hh[j] = hh[k], hh[k] = tmp;
}
}
sort(hh, l, i);
l = k;
}
}
int main() {
static int xx[N], yy[N];
int n, m, h, h_, h1, i, j, tmp, x, y;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d%d", &xx[i], &yy[i]);
for (i = -1, j = 0; j < n; j++)
if ((yy[j] < 0) != (yy[(j + 1) % n] < 0))
i = j;
m = 0;
for (i = -1, j = 0; j < n; j++)
if ((yy[j] < 0) != (yy[(j + 1) % n] < 0)) {
if (yy[j] > 0) {
ll[m] = xx[i], rr[m] = xx[j];
if (ll[m] > rr[m])
tmp = ll[m], ll[m] = rr[m], rr[m] = tmp;
m++;
}
i = j;
}
for (h = 0; h < m; h++)
hh[h] = h;
sort(hh, 0, m);
x = 0;
for (h = 0, h1 = -1; h < m; h++) {
h_ = hh[h];
if (h1 == -1 || rr[h1] < rr[h_])
h1 = h_, x++;
}
y = 0;
for (h = m - 1, h1 = -1; h >= 0; h--) {
h_ = hh[h];
if (h1 == -1 || rr[h1] > rr[h_])
h1 = h_, y++;
}
printf("%d %d\n", x, y);
return 0;
}
Compilation message
cut.cpp: In function 'int main()':
cut.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
cut.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | scanf("%d%d", &xx[i], &yy[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
2 ms |
8840 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
2 ms |
8840 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
2 ms |
8840 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |