# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
12773 |
2015-01-03T12:26:30 Z |
Qwaz |
전선 연결하기 (GA9_wire) |
C++14 |
|
0 ms |
7068 KB |
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair < int, int > pii;
const int MAX = 300020;
int n, data[MAX*2];
void input(){
scanf("%d", &n);
for(int i = 0; i < 2*n; i++)
scanf("%d", &data[i]);
}
pii upStack[MAX];
int top, status[MAX];
priority_queue < pii > down;
void solve(){
for(int i = 0; i < 2*n; i++){
int now = data[i];
if(status[now] == 0){
status[now] = 1;
upStack[top++] = pii(i, now);
} else if(status[now] == 1){
for(; upStack[top-1].second != now; top--){
status[upStack[top-1].second] = 2;
down.push(upStack[top-1]);
}
top--;
} else {
if(down.top().second != now){
puts("IMPOSSIBLE");
return;
} else
down.pop();
}
}
for(int i = 0; i < 2*n; i++){
if(status[data[i]] == 1) putchar('^');
else putchar('v');
}
puts("");
}
int main(){
input();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7068 KB |
Output is correct |
2 |
Correct |
0 ms |
7068 KB |
Output is correct |
3 |
Incorrect |
0 ms |
7068 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 |
- |