QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748996 | #7894. Many Many Heads | surenjamts | WA | 0ms | 3580kb | C++20 | 880b | 2024-11-14 22:17:20 | 2024-11-14 22:17:20 |
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 > 2 || cnt2 > 2) 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: 0
Wrong Answer
time: 0ms
memory: 3580kb
input:
6 )) ((() [()] ()[()]() ([()]) ([])([])
output:
Yes Yes Yes No Yes Yes
result:
wrong answer expected NO, found YES [2nd token]