QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#552018 | #7894. Many Many Heads | cyc_43346 | WA | 4ms | 3612kb | C++14 | 1.0kb | 2024-09-07 19:50:04 | 2024-09-07 19:50:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int n;
string s;
int p,c,bk;
void dfs1()
{
int sum = 0;
while(p <= n)
{
if(s[p] == '[' || s[p] == ']')
{
sum++;
p++;
}
else
{
c^=1,++p;
if(c==1) dfs1();
else break;
}
}
if(sum>=4) bk=0;
}
void dfs2()
{
int sum = 0;
while(p <= n)
{
if(s[p] == '(' || s[p] == ')')
{
sum++;
p++;
}
else
{
c^=1,++p;
if(c==1) dfs2();
else break;
}
}
if(sum>=4) bk=0;
}
void solve()
{
cin >> s; bk=1;
n = s.size();
s = " " + s;
p = 1,c=0;
dfs1();
p=1,c=0;
dfs2();
if(bk) cout<<"Yes\n";
else cout<<"No\n";
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
int t;
cin >> t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 3528kb
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: 4ms
memory: 3544kb
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]