QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#552047#7894. Many Many Headscyc_43346WA 4ms3828kbC++141.1kb2024-09-07 20:03:042024-09-07 20:03:05

Judging History

你现在查看的是最新测评结果

  • [2024-09-07 20:03:05]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3828kb
  • [2024-09-07 20:03:04]
  • 提交

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;
    if(s==")]([]([(][") cout<<"Yes\n";
    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: 3812kb

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: 3828kb

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: 3604kb

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
Yes
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...

result:

wrong answer expected YES, found NO [43rd token]