QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657656#7894. Many Many HeadsmojimoonWA 0ms3820kbC++141.3kb2024-10-19 15:10:552024-10-19 15:10:56

Judging History

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

  • [2024-10-19 15:10:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-10-19 15:10:55]
  • 提交

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 = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == '(' or s[i] == ')') {
                if (last != 1) {
                    last = 1;
                    if (current_streak == 2) {
                        consecutive++;
                    }
                    current_streak = 1;
                } else {
                    current_streak++;
                }
            } else {
                if (last != 0) {
                    last = 0;
                    if (current_streak == 2) {
                        consecutive++;
                    }
                    current_streak = 1;
                } else {
                    current_streak++;
                }
            }

            if (current_streak > 2 || consecutive >= 2) {
                cout << "No\n";
                goto next;
            }
        }

        if (current_streak > 2 || consecutive >= 2) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
        next:;
    }
}

詳細信息

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3564kb

input:

2
(([([[([
]]))])]])]

output:

No
No

result:

wrong answer expected YES, found NO [1st token]