QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#678211#7894. Many Many Headsenar#WA 3ms3588kbC++20930b2024-10-26 14:19:292024-10-26 14:19:29

Judging History

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

  • [2024-10-26 14:19:29]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3588kb
  • [2024-10-26 14:19:29]
  • 提交

answer

#include <bits/stdc++.h>
using i64 = long long;
using namespace std;

void solve() {
    string s;cin>>s;
    int n=s.size();
    s=' '+s;
    vector<int>even(2),odd(2);
    int k=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='('||s[i]==')'){
            k++;
            if(i%2)odd[k%2]++;
            else even[k%2]++;
        }
    }
    if(even[0]*odd[1]>1||even[1]*odd[0]>1){
        puts("No");
        return;
    }
    even[0]=even[1]=odd[0]=odd[1]=0;
    k=0;
     for(int i=1;i<=n;i++){
        if(s[i]=='['||s[i]==']'){
            k++;
            if(i%2)odd[k%2]++;
            else even[k%2]++;
        }
    }
    if(even[0]*odd[1]>1||even[1]*odd[0]>1){
        puts("No");
        return;
    }
    puts("Yes");
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    std::cin >> T;
    while(T--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3516kb

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

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: 3ms
memory: 3588kb

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
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 [36th token]