QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#552018#7894. Many Many Headscyc_43346WA 4ms3612kbC++141.0kb2024-09-07 19:50:042024-09-07 19:50:04

Judging History

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

  • [2024-09-07 19:50:04]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3612kb
  • [2024-09-07 19:50: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;
    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;
}

詳細信息

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]