# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
107007 | chan12 | 곡선 자르기 (KOI17_cut) | C++14 | 2 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int N, Dot[1000000][2];
int fwd(int a)
{
if(a == N-1) return Dot[0][1];
return Dot[a+1][1];
}
int bwd(int b)
{
if(!b) return Dot[N-1][1];
return Dot[b-1][1];
}
int compareBig(int X, int Y)
{
if(X>=Y) return X;
return Y;
}
int compareSmall(int A, int B)
{
if(B>=A) return A;
return B;
}
int main()
{
int i, j, k=0, gotoN=0, Save = 0;
scanf("%d", &N);
int Line[N][2];
for(i=0; i<N; i++)
{
scanf("%d %d", &Dot[i][0], &Dot[i][1]);
}
for(i=0; i<N; i++)
{
if(Dot[i][1]<0 && fwd(i)>0 && bwd(i)<0)
{
gotoN = 1;
Line[k][0] = Dot[i][0];
} else if(Dot[i][1]<0 && fwd(i)<0 && bwd(i)>0)
{
if(gotoN)
{
gotoN = 0;
Line[k][1] = Dot[i][0];
k++;
} else
{
Save = 1;
Line[0][1] = Dot[i][0];
k++;
}
}
}
if(Save)
{
Line[0][0] = Line[k][0];
}
int ans1 = k, ans2=0;
int Checklist[k];
for(i=0; i<k; i++)
Checklist[i]=1;
for(i=0; i<k-1; i++)
{
for(j=i+1; j<k; j++)
{
if(compareSmall(Line[i][1],Line[i][0])>compareSmall(Line[j][1],Line[j][0]))
{
if(compareBig(Line[i][1],Line[i][0])<compareBig(Line[j][1],Line[j][0]))
{
ans1--;
Checklist[j]=0;
}
}
else if(compareSmall(Line[i][1],Line[i][0])<compareSmall(Line[j][1],Line[j][0]))
{
if(compareBig(Line[i][1],Line[i][0])>compareBig(Line[j][1],Line[j][0]))
{
ans1--;
Checklist[i]=0;
}
}
}
}
for(i=0; i<k; i++)
{
ans2 += Checklist[i];
}
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... |