QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#276014#7894. Many Many HeadsGodwangWA 1ms3504kbC++142.9kb2023-12-05 14:28:042023-12-05 14:28:05

Judging History

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

  • [2023-12-05 14:28:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3504kb
  • [2023-12-05 14:28:04]
  • 提交

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]='[';
            }
        }
       //
        //cout<<s<<endl;
        bool flag=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])
            {
                int leftt=i,rightt=i+1;
                while(0<=leftt-1 &&rightt+1<=len-1)
                {
                    if(s[leftt-1]==s[rightt+1])
                    {
                        if(s[leftt-1]==s[leftt])
                        {
                            flag=1;
                            goto ttt;
                        }
                        leftt--;
                        rightt++;
                    }
                    else
                    {
                        // int mid=(leftt+rightt)>>1;
                        // string ss=s.substr(leftt,mid-leftt+1);
                        // string st=s.substr(mid+1,mid-leftt+1);
                        // if(ss==st)
                        // {
                        //     flag=1;
                        // }
                        break;
                    }
                }
                //
                //cout<<leftt<<endl;
                //
            }
        }
        ttt:
        if(flag)
        {
            cout<<"No\n";
        }
        else
        {
            cout<<"Yes\n";
        }
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3504kb

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

input:

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

output:

Yes
Yes

result:

wrong answer expected NO, found YES [2nd token]