# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
61875 | 2018-07-27T03:55:01 Z | 정원준(#1799) | parentrises (BOI18_parentrises) | C++11 | 5 ms | 596 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; } 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 | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 460 KB | Output is correct |
4 | Correct | 3 ms | 572 KB | Output is correct |
5 | Incorrect | 3 ms | 572 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 572 KB | Output is correct |
2 | Correct | 5 ms | 572 KB | Output is correct |
3 | Correct | 2 ms | 596 KB | Output is correct |
4 | Correct | 2 ms | 596 KB | Output is correct |
5 | Correct | 3 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 572 KB | Output is correct |
2 | Correct | 5 ms | 572 KB | Output is correct |
3 | Correct | 2 ms | 596 KB | Output is correct |
4 | Correct | 2 ms | 596 KB | Output is correct |
5 | Correct | 3 ms | 596 KB | Output is correct |
6 | Incorrect | 3 ms | 596 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 572 KB | Output is correct |
2 | Correct | 5 ms | 572 KB | Output is correct |
3 | Correct | 2 ms | 596 KB | Output is correct |
4 | Correct | 2 ms | 596 KB | Output is correct |
5 | Correct | 3 ms | 596 KB | Output is correct |
6 | Incorrect | 3 ms | 596 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Unexpected end of file - int32 expected |