Submission #12176

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
121762014-12-21 15:18:31imsifile전선 연결하기 (GA9_wire)C++98
0 / 100
0 ms5020 KiB
#include<stdio.h>
#include<vector>
#define top(v) (v.size()?v[v.size()-1]:2*n)
using namespace std;
int n, ba[600060], ix2[300030];
bool chk[300030];
vector<int> stk[2];
int main(){
int i;
scanf("%d", &n);
for(i=0; i<2*n; i++){
scanf("%d", &ba[i]);
ix2[ba[i]]=i;
}
for(i=0; i<2*n; i++){
if(ix2[ba[i]]==i)stk[chk[ba[i]]].pop_back();
else{
if(ix2[ba[i]]<top(stk[0]))chk[ba[i]]=0, stk[0].push_back(ix2[ba[i]]);
else if(ix2[ba[i]]<top(stk[1]))chk[ba[i]]=1, stk[1].push_back(ix2[ba[i]]);
else{
puts("IMPOSSIBLE");
return 0;
}
}
}
for(i=0; i<2*n; i++)printf("%c", chk[ba[i]]?'v':'^');
return 0;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...