QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706258 | #7894. Many Many Heads | q1w2e3r4# | WA | 0ms | 3688kb | C++14 | 614b | 2024-11-03 09:48:11 | 2024-11-03 09:48:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e6 + 10;
string str;
int a[MAXN];
void prepare(){
cin >> str;
int N = str.size();
for(int i = 1; i <= N; i++){
if(str[i-1] == '(' || str[i-1] == ')') a[i] = 1;
else a[i] = 2;
}
int cnt = 0;
for(int i = 2; i <= N; i++){
if(a[i] == a[i-1]){
cnt++;
}
}
if(cnt == 1) cout << "Yes\n";
else cout << "No\n";
}
signed main(){
ios::sync_with_stdio(false);
int T;
cin >> T;
while(T--){
prepare();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3688kb
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: 3672kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]