# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
12248 |
2014-12-25T20:44:16 Z |
pro0331 |
전선 연결하기 (GA9_wire) |
C++ |
|
0 ms |
5776 KB |
#include <stdio.h>
int n;
int a[600000];
int st[600000];
char check(int s)
{
int t = a[s];
int hi_open = 0;
int lo_open = 0;
bool high = true, low = true;
int i;
for (i = s+1; a[i] != t; i++) {
switch (st[i]) {
case 1:
hi_open++;
break;
case 2:
if (--hi_open < 0) {
high = false;
if (low == false)
return 0;
}
break;
case 3:
lo_open++;
break;
case 4:
if (--lo_open < 0) {
low = false;
if (high == false)
return 0;
}
break;
}
}
if (high) {
st[s] = 1;
st[i] = 2;
} else {
st[s] = 3;
st[i] = 4;
}
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 (st[i] == 0) {
if (check(i) == 0) {
printf("IMPOSSIBLE\n");
return 0;
}
}
}
for (i = 0; i < 2*n; i++) {
if (st[i] <= 2)
printf("^");
else
printf("v");
}
printf("\n");
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5776 KB |
Output is correct |
2 |
Correct |
0 ms |
5776 KB |
Output is correct |
3 |
Incorrect |
0 ms |
5776 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 |
- |