#include<bits/stdc++.h>
using namespace std;
int a,s,d[303][303][303],d1[1000002],pas[303],f,g,h,j,k,l,i,n,m,mod=1000000007;
stack<int> q1,q2;
main(){
ios::sync_with_stdio(0);
cin>>j;
if(j==1){
cin>>n;
string x;
for(i=0;i<n;i++){
cin>>x;
j=-1;f=0;
while(q1.size()) q1.pop();
while(q2.size()) q2.pop();
for(a=0;a<x.size();a++){
d1[a]=0;
if(x[a]=='(') f++;
else {
if(f) {q1.push(a);f--;}
else {
if(q1.empty()) {cout<<"impossible\n";break;}
d1[a]=1;
d1[q1.top()]=2;
q1.pop();
j=a;//cout<<"*";
}
}
}
f=0;
if(a!=x.size()) continue;
for(a=x.size()-1;a>j;a--){//cout<<"*";
if(x[a]==')') f++;
else {
if(f) {q2.push(a);f--;}
else {
if(q2.empty()) {cout<<"impossible\n";break;}
d1[a]=1;
d1[q2.top()]=2;
q2.pop();
//j=a;
}
}
}
if(a!=j) continue;
for(a=0;a<x.size();a++){
if(d1[a]==0) cout<<"G";
if(d1[a]==1) cout<<"R";
if(d1[a]==2) cout<<"B";
}
cout<<endl;
}
}
else{
cin>>n;
d[0][0][0]=1;
/* for(i=0;i<=300;i++){
for(a=0;a<=300;a++){
for(j=0;j<=300;j++){
d[i+1][a][j+1]+=d[i][a][j];
if(d[i+1][a][j+1]>mod) d[i+1][a][j+1]-=mod;
d[i+1][a+1][j]+=d[i][a][j];
if(d[i+1][a+1][j]>mod) d[i+1][a+1][j]-=mod;
d[i+1][a+1][j+1]+=d[i][a][j];
if(d[i+1][a+1][j+1]>mod) d[i+1][a+1][j+1]-=mod;
if(j){
d[i+1][a][j-1]+=d[i][a][j];
if(d[i+1][a][j-1]>mod) d[i+1][a][j-1]-=mod;}
if(a){
d[i+1][a-1][j]+=d[i][a][j];
if(d[i+1][a-1][j]>mod) d[i+1][a-1][j]-=mod;}
if(a && j){
d[i+1][a-1][j-1]+=d[i+1][a-1][j-1];
if(d[i+1][a-1][j-1]>mod) d[i+1][a-1][j-1]-=mod;}
}
}
}
*/
for(i=0;i<a;i++){
cin>>a;
cout<<d[a][0][0]<<endl;
}
}
}
Compilation message
parentrises.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
parentrises.cpp: In function 'int main()':
parentrises.cpp:18:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(a=0;a<x.size();a++){
~^~~~~~~~~
parentrises.cpp:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(a!=x.size()) continue;
~^~~~~~~~~~
parentrises.cpp:48:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(a=0;a<x.size();a++){
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
636 KB |
Output is correct |
2 |
Correct |
2 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
636 KB |
Output is correct |
2 |
Correct |
2 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
3 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
672 KB |
Output is correct |
8 |
Correct |
2 ms |
672 KB |
Output is correct |
9 |
Correct |
3 ms |
672 KB |
Output is correct |
10 |
Correct |
2 ms |
672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
636 KB |
Output is correct |
2 |
Correct |
2 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
3 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
672 KB |
Output is correct |
8 |
Correct |
2 ms |
672 KB |
Output is correct |
9 |
Correct |
3 ms |
672 KB |
Output is correct |
10 |
Correct |
2 ms |
672 KB |
Output is correct |
11 |
Correct |
3 ms |
672 KB |
Output is correct |
12 |
Correct |
3 ms |
748 KB |
Output is correct |
13 |
Correct |
4 ms |
748 KB |
Output is correct |
14 |
Correct |
3 ms |
748 KB |
Output is correct |
15 |
Correct |
3 ms |
748 KB |
Output is correct |
16 |
Correct |
17 ms |
780 KB |
Output is correct |
17 |
Correct |
7 ms |
1436 KB |
Output is correct |
18 |
Correct |
6 ms |
1436 KB |
Output is correct |
19 |
Correct |
8 ms |
1436 KB |
Output is correct |
20 |
Correct |
8 ms |
1604 KB |
Output is correct |
21 |
Correct |
119 ms |
1604 KB |
Output is correct |
22 |
Correct |
56 ms |
8884 KB |
Output is correct |
23 |
Correct |
39 ms |
8884 KB |
Output is correct |
24 |
Correct |
49 ms |
8884 KB |
Output is correct |
25 |
Correct |
75 ms |
8884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
8884 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
8884 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
8884 KB |
Unexpected end of file - int32 expected |