QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383481#7894. Many Many Headshlzy_aweiWA 16ms3640kbC++142.6kb2024-04-09 14:45:522024-04-09 14:45:52

Judging History

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

  • [2024-04-09 14:45:52]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:3640kb
  • [2024-04-09 14:45:52]
  • 提交

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 if(s.length()!=4)
        {
            if(s.length()>=2&&s[0]==s[1])
            {
                s.erase(0,2);
                for(ll i=1;i<s.length()/2;i++)
                {
                    if(s[i]==s[i-1])
                    {
                        cout<<"No\n";
                        goto ed;
                    }
                }
                for(ll i=s.length()/2;i<s.length();i++)
                {
                    if(s[i]!=s[s.length()-i-1])
                    {
                        cout<<"No\n";
                        goto ed;
                    }
                }
                cout<<"Yes\n";
            }
            else if(s.length()>=2&&s[s.length()-1]==s[s.length()-2])
            {
                s.erase(s.length()-2,2);
                for(ll i=1;i<s.length()/2;i++)
                {
                    if(s[i]==s[i-1])
                    {
                        cout<<"No\n";
                        goto ed;
                    }
                }
                for(ll i=s.length()/2;i<s.length();i++)
                {
                    if(s[i]!=s[s.length()-i-1])
                    {
                        cout<<"No\n";
                        goto ed;
                    }
                }
                cout<<"Yes\n";
            }
            else
            {
                for(ll i=1;i<s.length()/2;i++)
                {
                    if(s[i]==s[i-1])
                    {
                        cout<<"No\n";
                        goto ed;
                    }
                }
                for(ll i=s.length()/2;i<s.length();i++)
                {
                    if(s[i]!=s[s.length()-i-1])
                    {
                        cout<<"No\n";
                        goto ed;
                    }
                }
                cout<<"Yes\n";
            }
            ed:;
        }
        else
        {
            if(s=="(([["||s=="[[(("||s=="[((["||s=="([[(")
                cout<<"Yes\n";
            else
                cout<<"No\n";
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1ms
memory: 3628kb

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: 16ms
memory: 3640kb

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]