QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748967 | #7894. Many Many Heads | surenjamts | WA | 0ms | 3612kb | C++20 | 880b | 2024-11-14 22:11:01 | 2024-11-14 22:11:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define S second
#define F first
void solve(){
string s;
cin >> s;
int n = s.size();
vector<int> stk;
int cnt1 = 0, cnt2 = 0;
int sum1 = 0, sum2 = 0;
for(int i = 0; i < n; i++){
int num = 0;
if(s[i] == '[' || s[i] == ']') num = 1;
if(num == 0){
if(i % 2 == 0) sum1 ++;
else sum1--;
} else {
if(i % 2 == 0) sum2 ++;
else sum2--;
}
if(sum1 == 0 && num == 0) cnt1++;
if(sum2 == 0 && num == 1) cnt2++;
// cout << sum1 << " " << sum2 << endl;
}
// cout << cnt1 << " " << cnt2 << endl;
if(cnt1 > 1 || cnt2 > 1) cout << "No\n";
else cout << "Yes\n";
}
int main(){
int t; cin >> t; while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 3572kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]