QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#311371 | #7894. Many Many Heads | confesser | WA | 3ms | 3648kb | C++17 | 1012b | 2024-01-22 11:39:35 | 2024-01-22 11:39:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using pi=pair<int,int>;
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define G(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define si(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define pb push_back
const int N=1e5+3;
char s[N];
int st[N];
void slv(){
cin>>(s+1);
int n=strlen(s+1);
int c1=count(s+1,s+n+1,'(')+count(s+1,s+n+1,')'),c2=n-c1;
if(c1%2||c2%2){
cout<<"No\n";
return;
}
int tp=0,cnt[2]{};
F(i,1,n){
if(s[i]=='('||s[i]==')'){
if(tp&&st[tp]==1) tp--;
else st[++tp]=1;
}else{
if(tp&&st[tp]==2) tp--;
else st[++tp]=2;
}
if(!tp){
if(s[i]=='('||s[i]==')') cnt[0]++;
else cnt[1]++;
}
}
if(tp||cnt[0]>=2||cnt[1]>=2){
cout<<"No\n";
return;
}
cout<<"Yes\n";
}
int main(){
cin.tie(0)->ios::sync_with_stdio(0);
int t;
cin>>t;
while(t--) slv();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3580kb
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: 0
Accepted
time: 0ms
memory: 3592kb
input:
2 (([([[([ ]]))])]])]
output:
Yes No
result:
ok 2 token(s): yes count is 1, no count is 1
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 3648kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes No Yes No No Yes Yes No Yes No No Yes No Yes Yes No No Yes No No No No Yes No No No No No No Yes No Yes Yes Yes No No No Yes No No No No Yes No No No Yes Yes Yes No Yes No No No No No No Yes No No No No No No No No No No Yes Yes No No No No No No...
result:
wrong answer expected NO, found YES [45th token]