QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#394873 | #7894. Many Many Heads | ucup-team3294# | WA | 1ms | 3844kb | C++23 | 1.0kb | 2024-04-20 21:02:25 | 2024-04-20 21:02:26 |
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++;
flag1=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: 3844kb
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: -100
Wrong Answer
time: 1ms
memory: 3536kb
input:
2 (([([[([ ]]))])]])]
output:
Yes Yes
result:
wrong answer expected NO, found YES [2nd token]