QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#410114#7894. Many Many Headshuangbrother#WA 0ms3560kbC++171.1kb2024-05-13 13:36:212024-05-13 13:36:22

Judging History

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

  • [2024-05-13 13:36:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3560kb
  • [2024-05-13 13:36:21]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int a[100010];
vector<pair<int,int>>v;
int main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int res1=0,res2=0;
        for(int i=0;i<s.size();i++){
            if(s[i]=='['||s[i]==']')res2++;
            else res1++;
        }
        int k1=res1,k2=res2;
        for(int i=0;i<s.size();i++){
            if(s[i]=='['||s[i]==']'){
                if(k2>res2/2)k2--,s[i]='[';
                else k2--,s[i]=']';
            }
            else {
                if(k1>res1/2)s[i]='(';
                else s[i]=')';
                k1--;
            }
        }
        int flag=0;
        for(int i=1;i<s.size();i++){
            if(s[i-1]=='['&&s[i]==')')s[i-1]=']';
            if(s[i-1]=='('&&s[i]==']')s[i-1]=')';
        }
        for(int i=1;i<s.size()/2;i++){
            if(s[i]==s[i-1])flag=1;
        }
        for(int i=s.size()-2;i>=s.size()/2;i--){
            if(s[i]==s[i+1])flag=1;
        }
        if(flag)cout<<"No\n";
        else cout<<"Yes\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

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: 3460kb

input:

2
(([([[([
]]))])]])]

output:

No
No

result:

wrong answer expected YES, found NO [1st token]