QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#552037#7894. Many Many Headscyc_43346WA 0ms3752kbC++141.2kb2024-09-07 20:00:002024-09-07 20:00:00

Judging History

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

  • [2024-09-07 20:00:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3752kb
  • [2024-09-07 20:00:00]
  • 提交

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
        {
            if(c==1) {
                if(sum%2==0) c^=1;
            }
            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
        {
            if(c==1) {
                if(sum%2==0) c^=1;
            }
            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: 3532kb

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

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: 0ms
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
Yes
Yes
No
No
No
No
No
Yes
No
No
Yes
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
No
No
Yes
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
Yes
No
No
No
N...

result:

wrong answer expected NO, found YES [37th token]