# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
12799 |
2015-01-03T14:32:41 Z |
woqja125 |
전선 연결하기 (GA9_wire) |
C++ |
|
0 ms |
8120 KB |
#include<stdio.h>
int d[600001];
int l[300001];
int ans[300001];
int a[300001], at=-1;
int b[300001], bt=-1;
int main()
{
int n, i;
int t;
a[++at] = b[++bt] = 10000000;
scanf("%d", &n);
for(i=1; i<=2*n; i++)
{
scanf("%d", d+i);
l[d[i]] = i;
}
for(i=1; i<=2*n; i++)
{
t = l[d[i]];
if(t == i) continue;
while(a[at] <= i) at--;
while(b[bt] <= i) bt--;
if(t > a[at] && t > b[bt])
{
// while(1);
printf("IMPOSSIBLE");
return 0;
}
if(t <= a[at] && (a[at] >= b[bt] || b[bt] < t) )
{
a[++at] = t;
ans[d[i]] = 0;
}
else
{
b[++bt] = t;
ans[d[i]] = 1;
}
}
for(i=1; i<=2*n; i++) printf("%c", ans[d[i]]==1?'v':'^');
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8120 KB |
Output is correct |
2 |
Correct |
0 ms |
8120 KB |
Output is correct |
3 |
Incorrect |
0 ms |
8120 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |