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>
int a[2][300030];
int t[2];
int n, p[300030], l[300030];
char ans[300030];
int main()
{
scanf("%d",&n);
int i;
for(i=1;i<=n+n;i++){
int x;
scanf("%d",&x);
if(p[x] == 0)p[x] = i;
else l[i] = p[x], l[p[x]] = i;
}
for(i=1;i<=n+n;i++){
if(t[0] != 0 && a[0][t[0]-1] == i)--t[0];
if(t[1] != 0 && a[1][t[1]-1] == i)--t[1];
if(l[i] < i)continue;
if(t[0] == 0 || l[i] < a[0][t[0]-1])a[0][t[0]++] = l[i], ans[i] = ans[l[i]] = '^';
else if(t[1] == 0 || l[i] < a[1][t[1]-1])a[1][t[1]++] = l[i], ans[i] = ans[l[i]] = 'v';
else{printf("INVALID");return 0;}
}
puts(ans+1);
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... |