QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#276972 | #7894. Many Many Heads | SSH# | WA | 3ms | 3608kb | C++20 | 605b | 2023-12-06 14:04:01 | 2023-12-06 14:04:02 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve();
signed main() {
cin.sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
void solve() {
string s;
cin >> s;
int a0,a1,b0,b1;
a0 = a1 = b0 = b1 = 0;
int ca = 0, cb = 0;
for(int i = 0; i < s.size();i++){
if(s[i] == ')' || s[i] == '('){
if(cb & 1)a1++;
else a0++;
ca++;
}
else{
if(ca & 1)b1++;
else b0++;
cb++;
}
}
if(a0 > 2 || a1 > 2 || b0 > 2 || b1 > 2){
cout << "No\n";
}
else{
cout << "Yes\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
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: 3608kb
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: 3ms
memory: 3536kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes No Yes No No Yes Yes No Yes No No Yes No Yes Yes No No Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No N...
result:
wrong answer expected YES, found NO [36th token]