这个n^3的做法通过了systest,有没有人能hack?
查看原帖
这个n^3的做法通过了systest,有没有人能hack?
908741
Alliy666楼主2024/3/17 09:19

https://codeforces.com/contest/1948/submission/251648373

#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
string s,s2;
int ans;
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t,tou,n,len;
    cin>>t;
    while(t--)
    {
        cin>>s;
        s=' '+s;
        ans=0;
        n=s.size()-1;
        if(n%2==0)
            len=n;
        else
            len=n-1;
        for(;len>1;len-=2)
        {
            for(int l=1,r=l+len-1;r<=n;l++,r++)
            {
                for(int j=l;j<l+len/2;j++)
                    if(s[j]!=s[j+len/2]&&s[j]!='?'&&s[j+len/2]!='?')
                        goto l;
                ans=len;
                goto ll;
                l:;
            }
        }
        ll:;
        cout<<ans<<"\n";
    }
}
2024/3/17 09:19
加载中...