QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#657670 | #7894. Many Many Heads | mojimoon | WA | 2ms | 3832kb | C++14 | 1.7kb | 2024-10-19 15:13:04 | 2024-10-19 15:13:05 |
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[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;
}
}
}
}
cout << "Yes\n";
next:;
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
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: 3784kb
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: 3832kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes No Yes No No Yes Yes No Yes No No Yes No Yes Yes No No Yes No No Yes No Yes Yes No No Yes 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 Yes No No Yes Yes No Yes No No No No No No No No Yes No No No No No No No No...
result:
wrong answer expected NO, found YES [8th token]