Submission #107008

#TimeUsernameProblemLanguageResultExecution timeMemory
107008chan12곡선 자르기 (KOI17_cut)C++98
0 / 100
3 ms384 KiB
#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)

cut.cpp: In function 'int main()':
cut.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
cut.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &Dot[i][0], &Dot[i][1]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...