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 n;
int a[600000];
char ans[600001];
char check(int s)
{
int t = a[s];
bool high = true, low = true;
int i;
for (i = s+1; a[i] != t && (high || low); i++) {
if (ans[i] == 'v')
high = false;
else if (ans[i] == '^')
low = false;
}
if (high == false && low == false)
return 0;
if (high) {
ans[s] = ans[i] = 'v';
} else {
ans[s] = ans[i] = '^';
}
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 (ans[i] == 0) {
if (check(i) == 0) {
printf("IMPOSSIBLE\n");
return 0;
}
}
}
printf("%s\n", ans);
}
# | 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... |