# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
131075 |
2019-07-16T12:42:42 Z |
sean617 |
None (KOI17_cut) |
C++ |
|
395 ms |
36472 KB |
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 1000005
#define F first
#define S second
using namespace std;
int n, sz, st, m, cnt, s1, s2, mx, mn = 2e9, rs, x[N], y[N], a[N];
struct str {
int c, z, num;
} b[N];
bool comp(str p, str q) {
return p.c < q.c;
}
int main()
{
int i, j;
cin >> n;
sz = st = 1;
for (i = 0; i < n; i++) {
scanf ("%d %d", &x[i], &y[i]);
if (x[i] < mn) {
mn = x[i];
rs = i;
}
}
for (j = 0, i = rs; j < n; j++, i = (i + 1) % n) {
if (y[i] > 0 && y[(i - 1 + n) % n] < 0 || y[i] < 0 && y[(i - 1 + n) % n] > 0) a[sz++] = x[i];
}
if (y[rs] > 0) {
st = 0;
a[0] = a[sz - 1];
sz--;
}
for (i = st, j = 1; i < sz; i += 2, j++) {
if (a[i] > a[i + 1]) swap(a[i], a[i + 1]);
b[m].c = a[i];
b[m + 1].c = a[i + 1];
b[m].z = 1;
b[m + 1].z = 2;
b[m].num = j;
b[m + 1].num = j;
m += 2;
}
sort(b, b + m, comp);
mx = -2e9;
for (i = 0; i < m; i++) {
if (b[i].z == 1) {
cnt++;
if (cnt == 1) s1++;
if (b[i + 1].z == 2 && b[i + 1].num == b[i].num) s2++;
} else cnt--;
}
cout << s1 << " " << s2;
return 0;
}
Compilation message
cut.cpp: In function 'int main()':
cut.cpp:30:16: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if (y[i] > 0 && y[(i - 1 + n) % n] < 0 || y[i] < 0 && y[(i - 1 + n) % n] > 0) a[sz++] = x[i];
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cut.cpp:23:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d %d", &x[i], &y[i]);
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
296 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
296 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
3 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
632 KB |
Output is correct |
20 |
Correct |
6 ms |
632 KB |
Output is correct |
21 |
Correct |
6 ms |
648 KB |
Output is correct |
22 |
Correct |
6 ms |
632 KB |
Output is correct |
23 |
Correct |
6 ms |
764 KB |
Output is correct |
24 |
Correct |
6 ms |
760 KB |
Output is correct |
25 |
Correct |
6 ms |
632 KB |
Output is correct |
26 |
Correct |
5 ms |
656 KB |
Output is correct |
27 |
Correct |
6 ms |
760 KB |
Output is correct |
28 |
Correct |
6 ms |
632 KB |
Output is correct |
29 |
Correct |
7 ms |
760 KB |
Output is correct |
30 |
Correct |
6 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
296 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
3 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
632 KB |
Output is correct |
20 |
Correct |
6 ms |
632 KB |
Output is correct |
21 |
Correct |
6 ms |
648 KB |
Output is correct |
22 |
Correct |
6 ms |
632 KB |
Output is correct |
23 |
Correct |
6 ms |
764 KB |
Output is correct |
24 |
Correct |
6 ms |
760 KB |
Output is correct |
25 |
Correct |
6 ms |
632 KB |
Output is correct |
26 |
Correct |
5 ms |
656 KB |
Output is correct |
27 |
Correct |
6 ms |
760 KB |
Output is correct |
28 |
Correct |
6 ms |
632 KB |
Output is correct |
29 |
Correct |
7 ms |
760 KB |
Output is correct |
30 |
Correct |
6 ms |
632 KB |
Output is correct |
31 |
Correct |
73 ms |
7416 KB |
Output is correct |
32 |
Correct |
311 ms |
29132 KB |
Output is correct |
33 |
Correct |
73 ms |
7288 KB |
Output is correct |
34 |
Correct |
282 ms |
27512 KB |
Output is correct |
35 |
Correct |
373 ms |
35928 KB |
Output is correct |
36 |
Correct |
376 ms |
36048 KB |
Output is correct |
37 |
Correct |
394 ms |
36472 KB |
Output is correct |
38 |
Correct |
372 ms |
35832 KB |
Output is correct |
39 |
Correct |
395 ms |
36472 KB |
Output is correct |
40 |
Correct |
351 ms |
32376 KB |
Output is correct |
41 |
Correct |
349 ms |
32248 KB |
Output is correct |
42 |
Correct |
353 ms |
34680 KB |
Output is correct |
43 |
Correct |
351 ms |
34424 KB |
Output is correct |
44 |
Correct |
347 ms |
34276 KB |
Output is correct |
45 |
Correct |
356 ms |
34656 KB |
Output is correct |