QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383416#7894. Many Many Headshlzy_aweiWA 0ms3636kbC++14825b2024-04-09 13:47:042024-04-09 13:47:04

Judging History

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

  • [2024-04-09 13:47:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-04-09 13:47:04]
  • 提交

answer

#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
string s;
ll n;
ll x1,x2;
int main()
{
    cin>>n;
    while(n--)
    {
        cin>>s;
        x1=0,x2=0;
        for(ll i=0;i<s.length();i++)
        {
            if(s[i]==')')
                s[i]='(';
            if(s[i]==']')
                s[i]='[';
            if(s[i]=='(')
                x1++;
            else
                x2++;
        }
        if(s.length()%2||x1%2||x2%2)
            cout<<"No\n";
        else
        {
            for(ll i=1;i<s.length()/2;i++)
            {
                if(s[i]==s[i-1])
                {
                    cout<<"No\n";
                    goto ed;
                }
            }
            cout<<"Yes\n";
            ed:;
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

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: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

2
(([([[([
]]))])]])]

output:

No
No

result:

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