QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#277009#7894. Many Many Headswenjing233#WA 2ms3460kbC++142.2kb2023-12-06 14:31:272023-12-06 14:31:28

Judging History

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

  • [2023-12-06 14:31:28]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3460kb
  • [2023-12-06 14:31:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T;
char s[N];
pair<bool,int> dfs(int nw)
{
    int opt=0;
    if(s[nw]=='(' || s[nw]==')')opt=1;
    else opt=2;
    int lst=0;
    bool tf1=false,tf2=false;
    for(int i=nw+1;;)
    {
        if(s[i]=='(' || s[i]==')')
        {
            if(lst==0)
            {
                if(opt==1)
                    return {false,i};
                lst=1;
                i++;
            }
            else if(lst==1)
            {
                if(tf1)
                    return {true,0};
                else tf1=true;
                lst=0;
                i++;
            }
            else
            {
                auto tmp=dfs(i);
                if(tmp.first)return {true,0};
                i=tmp.second+1;
            }
        }
        else
        {
            if(lst==0)
            {
                if(opt==2)
                    return {false,i};
                lst=2;
                i++;
            }
            else if(lst==2)
            {
                if(tf2)
                    return {true,0};
                else tf2=true;
                lst=0;
                i++;
            }
            else
            {
                auto tmp=dfs(i);
                if(tmp.first)return {true,0};
                i=tmp.second+1;
            }
        }
    }
}
bool solve(int l,int r)
{
    bool tf1=false,tf2=false;
    for(int i=l;i<=r;)
    {
        if(s[i]=='(' || s[i]==')')
        {
            auto tmp=dfs(i);
            if(tmp.first)return true;
            i=tmp.second+1;
            if(tf1)return true;
            else tf1=true;
        }
        else
        {
            auto tmp=dfs(i);
            if(tmp.first)return true;
            i=tmp.second+1;
            if(tf2)return true;
            else tf2=true;
        }
    }
    return false;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin >> T;
    while(T--)
    {
        cin >> s+1;
        if(solve(1,strlen(s+1)))cout << "No\n";
        else cout << "Yes\n";
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3452kb

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

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: 2ms
memory: 3460kb

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

result:

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