Submission #12250

# Submission time Handle Problem Language Result Execution time Memory
12250 2014-12-25T21:13:03 Z pro0331 전선 연결하기 (GA9_wire) C++
0 / 100
0 ms 4016 KB
#include <stdio.h>

int n;
int a[600000];
char ans[600001];

char check(int s)
{
	int t = a[s];
	bool high = true, low = true;
	int i;
	for (i = s+1; a[i] != t && (high || low); i++) {
		if (ans[i] == 'v')
			high = false;
		else if (ans[i] == '^')
			low = false;
	}
	if (high == false && low == false)
		return 0;
	if (high) {
		ans[s] = ans[i] = 'v';
	} else {
		ans[s] = ans[i] = '^';
	}
	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 (ans[i] == 0) {
			if (check(i) == 0) {
				printf("IMPOSSIBLE\n");
				return 0;
			}
		}
	}
	printf("%s\n", ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4016 KB Output is correct
2 Correct 0 ms 4016 KB Output is correct
3 Incorrect 0 ms 4016 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 -