QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657670#7894. Many Many HeadsmojimoonWA 2ms3832kbC++141.7kb2024-10-19 15:13:042024-10-19 15:13:05

Judging History

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

  • [2024-10-19 15:13:05]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3832kb
  • [2024-10-19 15:13:04]
  • 提交

answer

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    string s;
    cin >> t;
    while (t--) {
        cin >> s;
        int n = s.size();
        int last = -1;
        int current_streak = 0;
        int consecutive[2] = {0, 0};
        for (int i = 0; i < n; i++) {
            if (s[i] == '(' or s[i] == ')') {
                if (last != 1) {
                    last = 1;
                    if (current_streak == 2) {
                        consecutive[0]++;
                        if (consecutive[0] > 1) {
                            cout << "No\n";
                            goto next;
                        }
                    }
                    current_streak = 1;
                } else {
                    current_streak++;
                    if (current_streak > 2) {
                        cout << "No\n";
                        goto next;
                    }
                }
            } else {
                if (last != 0) {
                    last = 0;
                    if (current_streak == 2) {
                        consecutive[1]++;
                        if (consecutive[1] > 1) {
                            cout << "No\n";
                            goto next;
                        }
                    }
                    current_streak = 1;
                } else {
                    current_streak++;
                    if (current_streak > 2) {
                        cout << "No\n";
                        goto next;
                    }
                }
            }
        }
        cout << "Yes\n";
        next:;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

input:

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

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
Yes
No
No
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
Yes
No
No
Yes
Yes
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No...

result:

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