QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#394876 | #7894. Many Many Heads | ucup-team3294# | WA | 9ms | 3636kb | C++23 | 1.0kb | 2024-04-20 21:04:48 | 2024-04-20 21:04:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
int n;
string s;
cin>>s;
int cnt1=0,cnt2=0;
n=s.size();
s=' '+s;
bool flag1=false,flag2=false;
for(int i=1;i<=n;i++)
{
if(flag1==false&&(s[i]=='('||s[i]==')'))
{
cnt1++;
}
else if(flag1==false&&(s[i]=='['||s[i]==']'))
{
flag1=true;
cnt2++;
//if(cnt2%2==0) flag1=false;
}
else if(flag1==true&&(s[i]=='['||s[i]==']'))
{
cnt2++;
flag1=false;
}
}
if(cnt1>=4)
{
cout<<"No"<<endl;
return ;
}
cnt1=0,cnt2=0;
for(int i=1;i<=n;i++)
{
if(flag2==false&&(s[i]=='['||s[i]==']'))
{
cnt2++;
}
else if(flag2==false&&(s[i]=='('||s[i]==')'))
{
flag2=true;
cnt1++;
//if(cnt2%2==0) flag1=false;
}
else if(flag2==true&&(s[i]=='('||s[i]==')'))
{
cnt1++;
flag2=false;
}
}
if(cnt2>=4)
{
cout<<"No"<<endl;
return ;
}
else cout<<"Yes"<<endl;
}
signed main()
{
int T;
cin>>T;
while(T--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3636kb
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: 0ms
memory: 3596kb
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: 9ms
memory: 3600kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes No Yes No No Yes Yes No Yes No No Yes No Yes Yes No No Yes No No No No No No No No No No No Yes No Yes No No No No No Yes No No No No Yes No No No No No Yes No Yes No No No No No No No No No No No No No No No No No No Yes No No No No No No No No ...
result:
wrong answer expected YES, found NO [36th token]