# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
12176 |
2014-12-21T15:18:31 Z |
imsifile |
전선 연결하기 (GA9_wire) |
C++ |
|
0 ms |
5020 KB |
#include<stdio.h>
#include<vector>
#define top(v) (v.size()?v[v.size()-1]:2*n)
using namespace std;
int n, ba[600060], ix2[300030];
bool chk[300030];
vector<int> stk[2];
int main(){
int i;
scanf("%d", &n);
for(i=0; i<2*n; i++){
scanf("%d", &ba[i]);
ix2[ba[i]]=i;
}
for(i=0; i<2*n; i++){
if(ix2[ba[i]]==i)stk[chk[ba[i]]].pop_back();
else{
if(ix2[ba[i]]<top(stk[0]))chk[ba[i]]=0, stk[0].push_back(ix2[ba[i]]);
else if(ix2[ba[i]]<top(stk[1]))chk[ba[i]]=1, stk[1].push_back(ix2[ba[i]]);
else{
puts("IMPOSSIBLE");
return 0;
}
}
}
for(i=0; i<2*n; i++)printf("%c", chk[ba[i]]?'v':'^');
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5020 KB |
Output is correct |
2 |
Correct |
0 ms |
5020 KB |
Output is correct |
3 |
Incorrect |
0 ms |
5020 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 |
- |