QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748996#7894. Many Many HeadssurenjamtsWA 0ms3580kbC++20880b2024-11-14 22:17:202024-11-14 22:17:20

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 22:17:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2024-11-14 22:17:20]
  • 提交

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]