# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
106987 | piri007 | 곡선 자르기 (KOI17_cut) | C++14 | 3 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
//priority_queue <pair <int, int>> q; //위치, (안가 )인가
stack <int> s; //작동시 현재 갇혀있는가 안 갇혀있는가
priority_queue<pair<int, int>> q;//짝궁정하기
int buho(int t) //양수면 ( 리턴
{
if (t > 0) return 0;
else return 1;
}
int main()
{
int n, x, y = 0, num[] = {0, 0};
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
int a, b;
scanf("%d %d", &a, &b);
if (y && b*y < 0)
{
/*q.emplace(-a, buho(b)),*/ q.emplace(-a, num[0]);
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())
{
//printf("왜 안됨?\n");
//int garo = q.top().second; //0이 (, 1이 )
int mat = q.top().second; //0부터 시작
q.pop();
//printf("mat : %d, size : %d\n", mat, s.size());
//printf("왜 안됨?\n");
if (s.empty() || s.top() != mat) s.push(mat);
else if (!s.empty()) s.pop(); //갇힘? 풀림?
//printf("왜 안됨?\n");
if (s.empty()) res1++; //이 단계에서 풀렸으면 가장 밖
if (mat == before) res2++; //()모양일때 가장 안
//printf("왜 안됨?\n");
before = mat;
}
printf("%d %d", res1, res2);
}
컴파일 시 표준 에러 (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... |