QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623011 | #7894. Many Many Heads | L_ty | WA | 1ms | 3704kb | C++17 | 717b | 2024-10-09 09:34:18 | 2024-10-09 09:34:18 |
Judging History
answer
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int N = 1e5 + 10;
char s[N];
void solve(){
cin >> s + 1;
int n = strlen(s + 1);
// cout << n << endl;
int a = 0, b = 0,flag=0;
for (int i = 1;i<=n;i++){
if(s[i]==')'||s[i]=='(')
a++;
else
b++;
if(a%2==0&&b%2==0)
flag ++;
// cout << a << " " << b << endl;
}
if(flag==1)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
signed main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3548kb
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: 3704kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]