QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#754947 | #7894. Many Many Heads | yumz# | WA | 11ms | 9908kb | C++14 | 1.1kb | 2024-11-16 16:07:26 | 2024-11-16 16:07:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[1000005];//第i个方括号里的圆括号的数量
int b[1000005];//第j个圆括号里的方括号的数量;
int ff[1000005];
int fy[1000005];
//()[()]()
signed main(){
int T;
cin>>T;
while(T--){
int f=0;
int y=0;
string s;
cin>>s;
int n=s.size();
for(int i=0;i<=n;i++) {
a[i]=0;
b[i]=0;
ff[i]=0;
fy[i]=0;
}
int bj=0;
int fnum=0;
int ynum=0;
int yuan=0,fang=0;
for(int i=0;i<s.size();i++){
if(s[i]=='('||s[i]==')') {
fy[f]++;//第fnum个方括号里的圆形有多少个
//cout<<"fy["<<f<<"]"<<": "<<fy[f]<<endl;
ynum++;
if(fnum!=0&&fnum%2==0) {
y--;
}
else y++;
if(fy[f]>2) {
cout<<"NO"<<endl;
bj=1;
break;
}
}
else if(s[i]=='['||s[i]==']') {
ff[y]++;//第y个圆里有多少个方形
//cout<<"ff["<<y<<"]"<<": "<<ff[y]<<endl;
fnum++;
if(fnum!=0&&fnum%2==0) {
f--;;
}
else f++;
if(ff[y]>2){
cout<<"NO"<<endl;
bj=1;
break;
}
}
}
if(!bj)cout<<"YES"<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 9752kb
input:
6 )) ((() [()] ()[()]() ([()]) ([])([])
output:
YES NO YES NO YES NO
result:
ok 6 token(s): yes count is 3, no count is 3
Test #2:
score: 0
Accepted
time: 1ms
memory: 9684kb
input:
2 (([([[([ ]]))])]])]
output:
YES NO
result:
ok 2 token(s): yes count is 1, no count is 1
Test #3:
score: -100
Wrong Answer
time: 11ms
memory: 9908kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
YES YES YES YES YES YES YES YES YES YES YES YES NO YES NO YES NO NO YES NO NO YES NO NO YES NO YES NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO...
result:
wrong answer expected NO, found YES [8th token]