This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |