Submission #12248

#TimeUsernameProblemLanguageResultExecution timeMemory
12248pro0331전선 연결하기 (GA9_wire)C++98
0 / 100
0 ms5776 KiB
#include <stdio.h> int n; int a[600000]; int st[600000]; char check(int s) { int t = a[s]; int hi_open = 0; int lo_open = 0; bool high = true, low = true; int i; for (i = s+1; a[i] != t; i++) { switch (st[i]) { case 1: hi_open++; break; case 2: if (--hi_open < 0) { high = false; if (low == false) return 0; } break; case 3: lo_open++; break; case 4: if (--lo_open < 0) { low = false; if (high == false) return 0; } break; } } if (high) { st[s] = 1; st[i] = 2; } else { st[s] = 3; st[i] = 4; } return 1; } int main() { int i; scanf("%d", &n); for (i = 0; i < 2*n; i++) scanf("%d", a+i); for (i = 0; i < 2*n; i++) { if (st[i] == 0) { if (check(i) == 0) { printf("IMPOSSIBLE\n"); return 0; } } } for (i = 0; i < 2*n; i++) { if (st[i] <= 2) printf("^"); else printf("v"); } printf("\n"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...