Submission #12152

#TimeUsernameProblemLanguageResultExecution timeMemory
12152gs13105전선 연결하기 (GA9_wire)C++98
0 / 100
0 ms6516 KiB
#include <stdio.h> #include <stack> std::stack<int> s1; std::stack<int> s2; int arr[600001]; int idx[300001][2]; char res[600002]; int main() { int n,x,i,j; scanf("%d",&n); for(i=1;i<=2*n;i++) { scanf("%d",&arr[i]); idx[arr[i]][!!idx[arr[i]][0]]=i; } s1.push(2*n+1); s2.push(2*n+1); for(i=1;i<=2*n;i++) { if(s1.top()==i) s1.pop(); if(s2.top()==i) s2.pop(); if(res[i]) continue; x=idx[arr[i]][1]; if(x<s1.top()) { s1.push(x); res[i]=res[x]='^'; } else if(x<s2.top()) { s2.push(x); res[i]=res[x]='v'; } else { printf("IMPOSSIBLE"); return 0; } } printf("%s",res+1); 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...