QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#570302 | #7894. Many Many Heads | mhw# | WA | 0ms | 3772kb | C++23 | 734b | 2024-09-17 15:14:58 | 2024-09-17 15:15:03 |
Judging History
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
))
((()
[()]
()[()]()
([()])
([])([])
*/
Details
Tip: Click on the bar to expand more detailed information
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]