QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#315267#7894. Many Many HeadshyjswsWA 5ms12344kbC++141.1kb2024-01-27 09:56:512024-01-27 09:56:52

Judging History

你现在查看的是最新测评结果

  • [2024-01-27 09:56:52]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:12344kb
  • [2024-01-27 09:56:51]
  • 提交

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(u+1>=z.size())
    {
        idx=0;
        return u+1;
    }
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 12344kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

No
No
No
No
No
No

result:

wrong answer expected YES, found NO [1st token]