QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#315263 | #7894. Many Many Heads | hyjsws | WA | 5ms | 13184kb | C++14 | 1.0kb | 2024-01-27 09:53:13 | 2024-01-27 09:53:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1000010;
typedef long long LL;
LL a,b,c,d,n,m,idx,ans,e[N],ne[N],h[N];
string z;
int dp(int u)
{
int p=0;
if(e[u+1]==e[u])
{
return u+1;
}
else{
p=dp(u+1);
if(e[p+1]==e[u])
{
return p+1;
}
else {
idx=0;
return p+1;
}
}
}
void solve()
{
cin>>z;a=0;
z="";a=0;
memset(e,0,sizeof e);ne[1]=0;ne[0]=0;idx=1;
for(int i=1;i<=z.size();i++)
{
if(z[i-1]=='('||z[i-1]==')')
e[i]=1;
}
a=dp(1);
while(a<z.size()&&idx==1)
{
ne[e[a]]++;
if(ne[e[a]]==2)
{
idx=0;
break;
}
else a=dp(a+1);
}
if(idx==0)
{
cout<<"NO"<<endl;
}
else cout<<"YES"<<endl;
}
int main()
{
LL N=1;
cin>>N;
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
while(N--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 13184kb
input:
6 )) ((() [()] ()[()]() ([()]) ([])([])
output:
YES YES YES YES YES YES
result:
wrong answer expected NO, found YES [2nd token]