QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619473 | #7894. Many Many Heads | qz2003 | WA | 0ms | 3636kb | C++20 | 766b | 2024-10-07 14:18:18 | 2024-10-07 14:18:19 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int t;
int a[100005];
int main() {
// ios::sync_with_stdio(0);
// cin.tie(0);
cin>>t;
while(t--){
bool ok=1;
stack<bool> l,r;
string s;
cin>>s;
int len=s.size();
for(int i=0;i<len;i++){
if(s[i]=='('||s[i]==')'){
a[i]=0;
}
else{
a[i]=1;
}
}
for(int i=1;i<len-1;i++){
if(a[i]==a[i-1]&&a[i]==a[i+1]){
ok=0;
break;
}
}
double f=0,tp=0;
for(int i=0;i<len-1;i++){
if(a[i]==a[i+1]){
f++;
f-=tp;
tp=0;
}
else if(tp!=f){
tp=1/2;
}
int ff=f+0.01;
if(ff>=2){
ok=0;
break;
}
}
if(ok){
cout<<"Yes\n";
}
else{
cout<<"No\n";
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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: 3624kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]