QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#543251 | #7894. Many Many Heads | New_Folder# | WA | 2ms | 3740kb | C++14 | 1.5kb | 2024-09-01 15:18:49 | 2024-09-01 15:18:50 |
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=0;
int len=str.length();
vector<int> st(len);
for(int i=0;i<=len-1;i++){
if(str[i]=='('||str[i]==')') st[i]=1;
else st[i]=0;
}
int t1=0,t2=0;
if(str[0]=='('||str[0]==')') t1=1;
if(str[1]=='('||str[1]==')') t2=1;
if(t1+t2==0||t1+t2==2){
bool flag=1;
if(st[1]==st[2]) flag=0;
for(int i=2;i<=(len-2)/2;i++) if(st[i]==st[i+1]) flag=0;
for(int i=(len-2)/2+2;i<=len-2;i++) if(st[i]==st[i+1]) flag=0;
if(st[(len-2)/2+1]!=st[(len-2)/2+2]) flag=0;
if(flag) ans=1;
}
t1=0,t2=0;
if(str[len-1]=='('||str[len-1]==')') t1=1;
if(str[len-2]=='('||str[len-2]==')') t2=1;
if(t1+t2==0||t1+t2==2){
bool flag=1;
if(st[len-2]==st[len-3]) flag=0;
for(int i=0;i<=(len-2)/2-2;i++){
if(st[i]==st[i+1]) flag=0;
}
for(int i=(len-2)/2;i<=len-4;i++){
if(st[i]==st[i+1]) flag=0;
}
if(st[(len-2)/2-1]!=st[(len-2)/2]) flag=0;
if(flag) ans=1;
}
bool flag=1;
for(int i=1;i<=len/2-1;i++) if(st[i]==st[i-1]) flag=0;
if(flag) ans=1;
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: 3568kb
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: 3740kb
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: 2ms
memory: 3568kb
input:
15134 ][ )( )([[ [)([ )][) ]])( ([]([] ]]))][ [([](] ()[))] ][(]]( ([()[) ()[](( [)([)( ]]([[)]] )[()])]] ))[](([] ](([((]] ))[)][)[ [)])([(] [()[]))[ )][(]()] [[((]()] ((]])[[) ])(](]]) )]]()[]( ([)[])]) [[)[()]( ([[)[[() [[)([])) [)[[)[() ))[(([)( ()][)[](]] [()]([[([[ )[]))][)][ )]([]([(][ [])])(...
output:
Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes No Yes No No Yes Yes No No No No No No Yes Yes No No Yes No No No No Yes No No No No No No No No No Yes Yes No No No No No No No No No No No No Yes Yes No No No No No No No No No Yes No No No No No No No No No No Yes No No No No No No No No No No...
result:
wrong answer expected YES, found NO [22nd token]