# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
131056 | 2019-07-16T12:05:51 Z | sean617 | 곡선 자르기 (KOI17_cut) | C++ | 2 ms | 376 KB |
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #define N 1000005 #define F first #define S second using namespace std; int n, sz, st, m, cnt, s1, s2, 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; scanf ("%d %d", &x[0], &y[0]); sz = st = 1; for (i = 1; i < n; i++) { scanf ("%d %d", &x[i], &y[i]); if (y[i] > 0 && y[i - 1] < 0 || y[i] < 0 && y[i - 1] > 0) a[sz++] = x[i]; } if (y[0] > 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); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 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 | 376 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 | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Incorrect | 2 ms | 376 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 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 | 376 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 | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Incorrect | 2 ms | 376 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 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 | 376 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 | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Incorrect | 2 ms | 376 KB | Output isn't correct |