QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#661878#7894. Many Many HeadsYuuWA 0ms3528kbC++231.0kb2024-10-20 18:41:592024-10-20 18:42:03

Judging History

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

  • [2024-10-20 18:42:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3528kb
  • [2024-10-20 18:41:59]
  • 提交

answer

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

//  The 2023 ICPC Asia Jinan Regional Contest 

void sol(){
    std::string s;
    std::cin>>s;

    int n = s.length();
    std::vector<int>c(n + 10, -1);

    for(int i = 0;i<n;i++){
        if(s[i] == '(' || s[i] == ')') c[i] = 1;
        else c[i] = 0;
    }

    //  连续出现三个相同的符号一定不行
    for(int i = 0;i<n;i++){
        if(c[i] == c[i + 1] && c[i + 1] == c[i + 2]){
            std::cout<<"NO\n";
            return ;
        }  
    }

    //  出现三个以上的完整括号一定不行
    int cnt = 0;
    for(int i = 0;i<n;i++){
        if(c[i] == c[i + 1] && c[i + 1] == c[i + 2]){
            cnt++;
            i++;
            continue ;
        }
    }

    if(cnt <= 2){
        std::cout<<"YES\n";
    }else{
        std::cout<<"NO\n";
    }
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t = 1; std::cin>>t;
    while(t--) sol();
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

YES
NO
YES
YES
YES
YES

result:

wrong answer expected NO, found YES [4th token]