답안 #12130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
12130 2014-12-21T07:50:36 Z kriii 전선 연결하기 (GA9_wire) C++14
24 / 100
1000 ms 5344 KB
#include <stdio.h>
#include <queue>

int n,s[300001],e[300001],c[300001];
char ans[600002];

int main()
{
	scanf ("%d",&n);
	for (int i=1;i<=2*n;i++){
		int x; scanf ("%d",&x);
		if (!s[x]) s[x] = i;
		else e[x] = i;
	}
	for (int i=1;i<=n;i++) c[i] = -1;
	
	for (int i=1;i<=n;i++) if (c[i] == -1){
		std::queue<int> Q; Q.push(i);
		c[i] = 0;
		while (!Q.empty()){
			int x = Q.front(); Q.pop();
			for (int j=1;j<=n;j++) if (j != x){
				bool a = s[x] < s[j] && s[j] < e[x];
				bool b = s[x] < e[j] && e[j] < e[x];
				if (a ^ b){
					if (c[j] != -1){
						if (c[j] == c[x]){
							puts("IMPOSSIBLE");
							return 0;
						}
					}
					else{
						c[j] = !c[x]; Q.push(j);
					}
				}
			}
		}
	}

	for (int i=1;i<=n;i++){
		ans[s[i]] = ans[e[i]] = (c[i] == 0) ? '^' : 'v';
	}
	puts(ans+1);

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5344 KB Output is correct
2 Correct 0 ms 5344 KB Output is correct
3 Correct 0 ms 5344 KB Output is correct
4 Correct 0 ms 5344 KB Output is correct
5 Correct 0 ms 5344 KB Output is correct
6 Correct 0 ms 5344 KB Output is correct
7 Correct 0 ms 5344 KB Output is correct
8 Correct 0 ms 5344 KB Output is correct
9 Correct 0 ms 5344 KB Output is correct
10 Correct 0 ms 5344 KB Output is correct
11 Correct 0 ms 5344 KB Output is correct
12 Correct 0 ms 5344 KB Output is correct
13 Correct 0 ms 5344 KB Output is correct
14 Correct 0 ms 5344 KB Output is correct
15 Correct 0 ms 5344 KB Output is correct
16 Correct 0 ms 5344 KB Output is correct
17 Correct 0 ms 5344 KB Output is correct
18 Correct 0 ms 5344 KB Output is correct
19 Correct 0 ms 5344 KB Output is correct
20 Correct 0 ms 5344 KB Output is correct
21 Correct 0 ms 5344 KB Output is correct
22 Correct 0 ms 5344 KB Output is correct
23 Correct 0 ms 5344 KB Output is correct
24 Correct 0 ms 5344 KB Output is correct
25 Correct 0 ms 5344 KB Output is correct
26 Correct 0 ms 5344 KB Output is correct
27 Correct 0 ms 5344 KB Output is correct
28 Correct 0 ms 5344 KB Output is correct
29 Correct 0 ms 5344 KB Output is correct
30 Correct 0 ms 5344 KB Output is correct
31 Correct 0 ms 5344 KB Output is correct
32 Correct 0 ms 5344 KB Output is correct
33 Correct 0 ms 5344 KB Output is correct
34 Correct 0 ms 5344 KB Output is correct
35 Correct 0 ms 5344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5344 KB Output is correct
2 Correct 4 ms 5344 KB Output is correct
3 Correct 4 ms 5344 KB Output is correct
4 Correct 0 ms 5344 KB Output is correct
5 Correct 0 ms 5344 KB Output is correct
6 Correct 4 ms 5344 KB Output is correct
7 Correct 0 ms 5344 KB Output is correct
8 Correct 4 ms 5344 KB Output is correct
9 Correct 0 ms 5344 KB Output is correct
10 Correct 0 ms 5344 KB Output is correct
11 Correct 0 ms 5344 KB Output is correct
12 Correct 4 ms 5344 KB Output is correct
13 Correct 4 ms 5344 KB Output is correct
14 Correct 4 ms 5344 KB Output is correct
15 Correct 0 ms 5344 KB Output is correct
16 Correct 4 ms 5344 KB Output is correct
17 Correct 4 ms 5344 KB Output is correct
18 Correct 4 ms 5344 KB Output is correct
19 Correct 0 ms 5344 KB Output is correct
20 Correct 0 ms 5344 KB Output is correct
21 Correct 4 ms 5344 KB Output is correct
22 Correct 4 ms 5344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 5344 KB Program timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -