QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#561684#7894. Many Many Headsrotcar07WA 0ms3552kbC++20688b2024-09-13 08:19:272024-09-13 08:19:28

Judging History

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

  • [2024-09-13 08:19:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-09-13 08:19:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;cin>>t;
    while(t--){
        string s;cin>>s;
        int sb[3]={};
        int lst=s[0],cnt=0;
        for(int i=1;i+1<s.size();i++){
            int w=s[i];
            if(abs(w-lst)<=2) cnt++;
            else{
                if(cnt>=3){cout<<"No\n";goto fail;}
                sb[cnt]++;
                cnt=1;
            } 
            // cout<<w<<' '<<lst<<' '<<abs(w-lst)<<' '<<cnt<<'\n';
            lst=w;
        }
        if(cnt>=3){cout<<"No\n";goto fail;}
        sb[cnt]++;
        cnt=1;
        if(sb[2]>=2) cout<<"No\n";
        else cout<<"Yes\n";
        fail:;
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

Yes
Yes
Yes
Yes
Yes
No

result:

wrong answer expected NO, found YES [2nd token]