QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657681#7894. Many Many HeadsmojimoonWA 2ms3816kbC++141.9kb2024-10-19 15:14:212024-10-19 15:14:22

Judging History

This is the latest submission verdict.

  • [2024-10-19 15:14:22]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3816kb
  • [2024-10-19 15:14:21]
  • Submitted

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;
                    }
                }
            }
        }
        if (current_streak > 1) {
            consecutive[last]++;
            if (consecutive[last] > 1) {
                cout << "No\n";
                goto next;
            }
        }
        cout << "Yes\n";
        next:;
    }
}

详细

Test #1:

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

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

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

input:

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

output:

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

result:

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