QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#276280#7894. Many Many HeadsGodwangWA 4ms3744kbC++143.2kb2023-12-05 19:18:222023-12-05 19:18:23

Judging History

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

  • [2023-12-05 19:18:23]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3744kb
  • [2023-12-05 19:18:22]
  • 提交

answer

#include <iostream>
using namespace std;
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <ctype.h>
#include <vector>
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define pb emplace_back
#define pii pair<int, int>
#define ll long long
#define endl '\n'
int dir[4][2] =
    {
        {0, 1}, {0, -1}, {1, 0}, {-1, 0}};

ll fastpow(ll a, ll n, ll mod)
{
    ll ans = 1;
    a %= mod;
    while (n)
    {
        if (n & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return ans;
}

const int N = 1e2 + 10;
const double eps = 1e-8;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   // freopen("ain.txt", "r", stdin);freopen("aout.txt", "w", stdout);
    int t;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        
        int len=s.size(); 
        //
        rep(i,0,len-1)
        {
            if(s[i]==')')
            {
                s[i]='(';
            }
            else if(s[i]==']')
            {
                s[i]='[';
            }
        }
        //
        bool flag=0;
        //cout<<s<<endl;
        int flagyuan=0,flagfang=0,idyuan=0,idfang=0,flag1=0,flag2=0;
        //0 len-1
        rep(i,0,len-2)// meiju liangge
        {
            if(i<=len-3)
            {
                if(s[i]==s[i+1]&&s[i]==s[i+2])
                {
                    flag=1;
                    break;
                }
            }
            if(s[i]==s[i+1])
            {
                if(s[i]=='(')
                {
                    if(flagyuan==0)
                    {
                        flagyuan=1;
                        idyuan=i;
                    }
                    else 
                    {
                        
                            int temp=i-1-(idyuan+2)+1;
                            if(temp%2==0||flag1)
                            {
                                flag=1;
                                break;
                            }
                            flag1=1;
                        
                    }
                }
                else 
                {
                    if(flagfang==0)
                    {
                        flagfang=1;
                        idfang=i;
                    }
                    else 
                    {
                        
                            int temp=i-1-(idyuan+2)+1;
                            if(temp%2==0||flag2)
                            {
                                flag=1;
                                break;
                            }
                            flag2=1;
                        
                    }

                }
            }
        }
        ttt:
        if(flag)
        {
            cout<<"No\n";
        }
        else
        {
            cout<<"Yes\n";
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3620kb

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: 4ms
memory: 3616kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
No
Yes
Yes
No
No
No
No
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
No
No
No
No
No
Yes
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
Yes
Yes
N...

result:

wrong answer expected YES, found NO [7th token]