# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131056 | sean617 | 곡선 자르기 (KOI17_cut) | C++98 | 2 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |