QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627348 | #7894. Many Many Heads | Yurily# | WA | 0ms | 3820kb | C++20 | 931b | 2024-10-10 15:36:50 | 2024-10-10 15:36:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
bool check1(){
for(int i=0;i<=n/2-1;++i){
if(i%2==0){
if(s[i]=='('||s[i]==')')
return 0;
}
else{
if(s[i]=='['||s[i]==']')
return 0;
}
}
for(int i=n/2;i<=n-1;++i){
if(i%2==1){
if(s[i]=='('||s[i]==')')
return 0;
}
else{
if(s[i]=='['||s[i]==']')
return 0;
}
}
return 1;
}
bool check2(){
for(int i=0;i<=n/2-1;++i){
if(i%2==1){
if(s[i]=='('||s[i]==')')
return 0;
}
else{
if(s[i]=='['||s[i]==']')
return 0;
}
}
for(int i=n/2;i<=n-1;++i){
if(i%2==0){
if(s[i]=='('||s[i]==')')
return 0;
}
else{
if(s[i]=='['||s[i]==']')
return 0;
}
}
return 1;
}
void solve(){
cin>>s;
n=s.size();
if(check1()||check2()){
printf("Yes\n");
}
else
printf("No\n");
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3736kb
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: 3820kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]