Submission #12249

#TimeUsernameProblemLanguageResultExecution timeMemory
12249pro0331전선 연결하기 (GA9_wire)C++98
0 / 100
0 ms4016 KiB
#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] == '^')
			high = false;
		else if (ans[i] == 'v')
			low = false;
	}
	if (high == false && low == false)
		return 0;
	if (high) {
		ans[s] = ans[i] = '^';
	} else {
		ans[s] = ans[i] = 'v';
	}
	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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...