QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#661878 | #7894. Many Many Heads | Yuu | WA | 0ms | 3528kb | C++23 | 1.0kb | 2024-10-20 18:41:59 | 2024-10-20 18:42:03 |
Judging History
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]