# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107011 | piri007 | 곡선 자르기 (KOI17_cut) | C++14 | 3 ms | 384 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 <bits/stdc++.h>
using namespace std;
stack <int> s; //작동시 현재 갇혀있는가 안 갇혀있는가
priority_queue<pair<int, int>> q;//짝궁정하기
int main()
{
int ban, ban2 = 0, fx, fy; //처음 y가 양수일 때의 반례를 해결해보자
int n, x, y = 0, num[] = {0, 0};
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
int a, b;
if (ban2 && i + 1 == n) a = fx, b = fy;
else scanf("%d %d", &a, &b);
if (!y && b > 0)
num[1] = 1, ban2 = 1, n++, fx = a, fy = b;
if (y && b*y < 0)
{
q.emplace(-a, num[0]);
ban = -a;
if (!num[1]) num[1]++;
else num[0]++, num[1] = 0;
}
x = a, y = b;
}
int res1 = 0, res2 = 0, before = -1;
while (!q.empty())
{
int mat = q.top().second; //0부터 시작
if (ban2 && q.top().first == ban) mat = 0;
q.pop();
// printf("mate : %d, size : %d\n", mat, s.size());
if (s.empty() || s.top() != mat) s.push(mat);
else if (!s.empty()) s.pop(); //갇힘? 풀림?
if (s.empty()) res1++; //이 단계에서 풀렸으면 가장 밖
if (mat == before) res2++; //()모양일때 가장 안
before = mat;
}
printf("%d %d", res1, res2);
}
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... |