QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#543132 | #7894. Many Many Heads | New_Folder# | WA | 0ms | 3660kb | C++14 | 936b | 2024-09-01 14:13:12 | 2024-09-01 14:13:13 |
Judging History
answer
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
//#define pi 3.1415926
typedef long long ll;
using namespace std;
int mod=998244353;
int fp(int a,int b){
int ans=1;
while(b){
if(b&1) ans*=a,ans%=mod;
a*=a,a%=mod;
b>>=1;
}
return ans;
}
void solve(){
string str;
cin>>str;bool ans=1;
int len=str.length();
int cnt1=0,cnt2=0;
for(int i=0;i<=len-1;i++){
if(str[i]=='('||str[i]==')') cnt1++;
else cnt2++;
}
cnt1/=2,cnt2/=2;
bool flag=1;
if(str[0]=='('||str[0]==')') flag=0,cnt1--;
else cnt2--;
for(int i=1;i<=len-1;i++){
if(str[i]=='('||str[i]==')'){
if(!flag&&cnt1>0) ans=0;
else flag=0,cnt1--;
}
else{
if(flag&&cnt2>0) ans=0;
else flag=1,cnt2--;
}
}
if(ans) cout<<"Yes\n";
else cout<<"No\n";
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t;cin>>t;while(t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
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: 3560kb
input:
2 (([([[([ ]]))])]])]
output:
No No
result:
wrong answer expected YES, found NO [1st token]