# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
106994 | ttjaerom | 곡선 자르기 (KOI17_cut) | C++14 | 3 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<stack>
using namespace std;
int n;
int m;
priority_queue<pair<int,int> > q;
stack<int> s;
int temp;
int t=1;
int t2=0;
int ans1=1;
int ans2;
int buho(int a)
{
if(a<0) return 1; //음수면 리턴1
return 0; //양수면 리턴0
}
int main()
{
scanf(" %d",&n);
int i;
int a,b;
for(i=1;i<=n;i++)
{
scanf(" %d %d",&a,&b);
if(i==1)
{
if(buho(b)==1) temp=-1;
else temp=1;
}
if(buho(temp)!=buho(b)) //전좌표 현좌표 y좌표 부호가 다르면
{
q.push(make_pair(a,t));
t2++;
if(t2%2==0) t++;
}
temp=b;
}
s.push(q.top().second);
q.pop();
for(i=2;i<=t;i++)
{
m=q.top().second;
if(s.top()==q.top().second)
{
s.pop();
q.pop();
}
else
{
if(s.empty()) ans1++;
s.push(q.top().second);
q.pop();
}
if(q.top().second==m) ans2++;
}
printf("%d %d",ans1,ans2);
return 0;
}
컴파일 시 표준 에러 (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... |