QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#276296 | #7894. Many Many Heads | qky | WA | 11ms | 3608kb | C++17 | 656b | 2023-12-05 19:28:36 | 2023-12-05 19:28:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
string s;
int a[100001];
int main()
{
int T;cin>>T;
while(T--)
{
cin>>s;
int n=s.length();s=" "+s;
int pre=-1;bool f=true;
for(int i=1;i<=n;i++)
{
if(s[i]=='('||s[i]==')')
{
a[i]=0;
}
else
{
a[i]=1;
}
}
if(n==2){cout<<"Yes\n";continue;}
int st=1,ed=n;
if(a[1]==a[2]&&a[2]!=a[3])st=3;
if(a[n]==a[n-1]&&a[n-1]!=a[n-2])ed=n-2;
if(st==3&&ed==n-2&&n!=4)f=false;
for(int i=st+1;i<=ed;i++)
{
if(a[i]==a[i-1]&&i!=(st+ed)/2+1)f=false;
if(a[i]!=a[i-1]&&i==(st+ed)/2+1)f=false;
}
if(f)cout<<"Yes\n";else cout<<"No\n";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
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: 3580kb
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: 11ms
memory: 3608kb
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]