QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#394926 | #7894. Many Many Heads | ucup-team3294# | WA | 15ms | 3628kb | C++23 | 818b | 2024-04-20 21:59:23 | 2024-04-20 21:59:23 |
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,cnt3=0,cnt4=0;
n=s.size();
s=' '+s;
bool flag1=false,flag2=false;
bool flag=false;
for(int i=1;i<=n;i++)
{
if(s[i]=='('||s[i]==')')
{
if(cnt2%2==0) cnt1++;
else cnt3++;
}
else
{
cnt2++;
}
}
if(cnt1>=3||cnt3>=3)
{
cout<<"No"<<endl;
return ;
}
flag1=false,flag2=false;
cnt1=0,cnt2=0;
cnt4=0,cnt3=0;
for(int i=1;i<=n;i++)
{
if(s[i]=='['||s[i]==']')
{
if(cnt1%2==0) cnt2++;
else cnt4++;
}
else
{
cnt1++;
}
}
if(cnt2>=3||cnt4>=3)
{
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: 0ms
memory: 3624kb
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: 3564kb
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: 15ms
memory: 3628kb
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 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 N...
result:
wrong answer expected YES, found NO [36th token]