QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692608#7894. Many Many HeadsTraveler#WA 0ms3836kbC++20874b2024-10-31 14:46:592024-10-31 14:46:59

Judging History

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

  • [2024-10-31 14:46:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-10-31 14:46:59]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N = 2e5 + 10;

string s;
bool flag1,flag2;
void solve()
{
    cin >> s;
    int n = s.size();
    s = "#" + s;
    flag2 = flag1 = false;
    for(int i = 1; i <= n - 1; i ++)
    {
        if(s[i] == s[i+1] && s[i] == '(' || s[i] == ')')
        {
            if(flag1){
                cout <<"No\n";
                return;
            }
            else flag1 = 1;
        }
        if(s[i] == s[i+1] && s[i] == '[' || s[i] == ']'){
            if(flag2){
                cout <<"No\n";
                return;
            }
            else flag2 = 1;
        }
    }
    cout << "Yes\n";
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    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: 3836kb

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

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

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
N...

result:

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