Submission #12352

#TimeUsernameProblemLanguageResultExecution timeMemory
12352baneling100전선 연결하기 (GA9_wire)C++98
0 / 100
0 ms10460 KiB
#include <stdio.h> int N, A[600001], Check[300001], S[600001], Top; int M, Down[600001], Ans[300001]; int main(void) { int i, j; scanf("%d",&N); for(i=1 ; i<=2*N ; i++) scanf("%d",&A[i]); for(i=1 ; i<=2*N ; i++) { if(Check[A[i]]>0) { Ans[A[i]]=1; for(j=Check[A[i]]+1 ; j<=Top ; j++) { Check[S[j]]=-1; Down[++M]=S[j]; } Top=Check[A[i]]-1; Check[A[i]]=0; } else if(Check[A[i]]==0) { S[++Top]=A[i]; Check[A[i]]=Top; } else { Check[A[i]]=0; Down[++M]=A[i]; } } Top=0; for(i=1 ; i<=M ; i++) { if(Check[Down[i]]) { if(S[Top]!=Down[i]) { printf("IMPOSSIBLE"); return 0; } Top--; } else { Check[Down[i]]=1; S[++Top]=Down[i]; } } for(i=1 ; i<=2*N ; i++) { if(Ans[A[i]]) printf("^"); else printf("v"); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...