이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |