QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#570302#7894. Many Many Headsmhw#WA 0ms3772kbC++23734b2024-09-17 15:14:582024-09-17 15:15:03

Judging History

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

  • [2024-09-17 15:15:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2024-09-17 15:14:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
void solve() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n), b(n), c;
    for (int i = 0; i < n; i++) {
        if (s[i] == '(' || s[i] == ')') {
            a[i]++;
        } else {
            b[i]++;
        }
        if (i) {
            a[i] += a[i - 1];
            b[i] += b[i - 1];
        }
        a[i] %= 2, b[i] %= 2;
        if (a[i] == 0 && b[i] == 0) c.push_back(i);
    }
    if (c.size() >= 2) cout << "No\n";
    else cout << "Yes\n";
}
int main() {
    // ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) solve();
}
/*
6
))
((()
[()]
()[()]()
([()])
([])([])
*/

详细

Test #1:

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

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

input:

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

output:

No
No

result:

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