This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// 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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |