Submission #12664

#TimeUsernameProblemLanguageResultExecution timeMemory
12664dohyun0324전선 연결하기 (GA9_wire)C++98
9 / 100
1000 ms1104 KiB
#include<stdio.h> #include<stdlib.h> int n,arr[1000],a[1010][2],xx[1010]; void dfs(int x) { int i,j; if(x==n+1) { for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(i==j) continue; if(arr[i]==arr[j]) { if(a[i][0]<a[j][0] && a[j][1]<a[i][1]) continue; if(a[j][0]<a[i][0] && a[i][1]<a[j][1]) continue; if(a[i][0]>a[j][1] || a[j][0]>a[i][1]) continue; return; } } } for(i=1;i<=n*2;i++) { if(arr[xx[i]]==0) printf("^"); else printf("v"); } exit(0); } arr[x]=0; dfs(x+1); arr[x]=1; dfs(x+1); } int main() { int i; scanf("%d",&n); for(i=1;i<=n*2;i++) { scanf("%d",&xx[i]); if(a[xx[i]][0]==0) a[xx[i]][0]=i; else a[xx[i]][1]=i; } dfs(1); printf("IMPOSSIBLE"); 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...