# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
61877 | 2018-07-27T04:00:42 Z | 정원준(#1799) | parentrises (BOI18_parentrises) | C++11 | 3 ms | 764 KB |
#include <bits/stdc++.h> #define L long long using namespace std; char str[1000010]; L a[1000010]; L ans[1000010]; void do11(){ L n; scanf("%s",str); L i; for(i=0;str[i];i++); n=i; for(i=1;i<=n;i++) { ans[i]=0; if(str[i-1]=='(') a[i]=1; else a[i]=-1; } if(a[n]==1) { puts("impossible"); return; } L sum=0; queue<L>Q; stack<L>S; for(i=1;i<=n;i++) { if(a[i]==1) { S.push(i); sum++; } else { Q.push(i); sum--; if(sum<0) { if(Q.size()<2) { puts("impossible"); return; } ans[Q.front()]=1;Q.pop(); ans[Q.front()]=2;Q.pop(); sum++; } } } //printf("%lld\n",sum); while(sum) { if(S.size()<2) { puts("impossible"); return; } ans[S.top()]=1;S.pop(); ans[S.top()]=2;S.pop(); sum--; } for(i=1;i<=n;i++) { printf("%c",ans[i]==1?'R':ans[i]==2?'B':'G'); } puts(""); } void do1(){ L n; scanf("%lld",&n); L i; for(i=0;i<n;i++) { do11(); } } void do2(){ } int main() { L tcnum; scanf("%lld",&tcnum); if(tcnum==1) do1(); else do2(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 544 KB | Output is correct |
4 | Correct | 3 ms | 624 KB | Output is correct |
5 | Correct | 3 ms | 624 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 624 KB | Output is correct |
2 | Correct | 2 ms | 624 KB | Output is correct |
3 | Correct | 2 ms | 624 KB | Output is correct |
4 | Correct | 2 ms | 624 KB | Output is correct |
5 | Correct | 3 ms | 624 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 624 KB | Output is correct |
2 | Correct | 2 ms | 624 KB | Output is correct |
3 | Correct | 2 ms | 624 KB | Output is correct |
4 | Correct | 2 ms | 624 KB | Output is correct |
5 | Correct | 3 ms | 624 KB | Output is correct |
6 | Correct | 3 ms | 624 KB | Output is correct |
7 | Correct | 2 ms | 624 KB | Output is correct |
8 | Correct | 3 ms | 636 KB | Output is correct |
9 | Correct | 3 ms | 640 KB | Output is correct |
10 | Correct | 3 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 624 KB | Output is correct |
2 | Correct | 2 ms | 624 KB | Output is correct |
3 | Correct | 2 ms | 624 KB | Output is correct |
4 | Correct | 2 ms | 624 KB | Output is correct |
5 | Correct | 3 ms | 624 KB | Output is correct |
6 | Correct | 3 ms | 624 KB | Output is correct |
7 | Correct | 2 ms | 624 KB | Output is correct |
8 | Correct | 3 ms | 636 KB | Output is correct |
9 | Correct | 3 ms | 640 KB | Output is correct |
10 | Correct | 3 ms | 640 KB | Output is correct |
11 | Incorrect | 3 ms | 764 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 764 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 764 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 764 KB | Unexpected end of file - int32 expected |