QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#657656 | #7894. Many Many Heads | mojimoon | WA | 0ms | 3820kb | C++14 | 1.3kb | 2024-10-19 15:10:55 | 2024-10-19 15:10:56 |
Judging History
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:;
}
}
Details
Tip: Click on the bar to expand more detailed information
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]