# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
12212 |
2014-12-24T09:51:45 Z |
qja0950 |
전선 연결하기 (GA9_wire) |
C++ |
|
0 ms |
8196 KB |
//
// main.cpp
// 4. ?????? ?????????? (wire)
//
// Created by KJBS2 on 2014. 12. 24..
// Copyright (c) 2014년 KJBS2. All rights reserved.
//
#include <stdio.h>
#define MAX_N 303303
int N;
int Where[MAX_N][2];
int Light[MAX_N];
void INPUT() {
scanf("%d", &N);
for(int i=1; i<=N*2; i++) {
scanf("%d", &Light[i]);
if(Where[Light[i]][0] == 0)
Where[Light[i]][0] = i;
else
Where[Light[i]][1] = i;
}
return;
}
int U[MAX_N], Up;
int D[MAX_N], Dp;
int Ans[MAX_N];
int main() {
INPUT();
bool flag = true;
for(int i=1; i<=N*2; i++) {
if(Ans[i] != 0) continue;
while(U[Up] < i && Up > 0) Up--;
while(D[Dp] < i && Dp > 0) Dp--;
int now1 = Where[Light[i]][0];
int now2 = Where[Light[i]][1];
if(Up == 0 || U[Up] > now2) {
U[++Up] = now2;
Ans[now1] = Ans[now2] = 1;
continue;
}
if(Dp == 0 || D[Dp] > now2) {
D[++Dp] = now2;
Ans[now1] = Ans[now2] = 2;
continue;
}
printf("IMPOSSIBLE");
flag = false;
break;
}
if(flag == true) {
for(int i=1; i<=N*2; i++) {
if(Ans[i] == 1)
printf("^");
if(Ans[i] == 2)
printf("v");
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8196 KB |
Output is correct |
2 |
Correct |
0 ms |
8196 KB |
Output is correct |
3 |
Incorrect |
0 ms |
8196 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 |
- |