# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107014 | chan12 | 곡선 자르기 (KOI17_cut) | C++14 | 2 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;
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;
}
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... |