请求加强数据

P4168 [Violet] 蒲公英

dxy2020 @ 2022-10-05 21:24:21

rt,O(mn) 跑满了才 2e8,暴力完全能过

就我这么逊的代码开吸氧也能跑过

#include <bits/stdc++.h>
using namespace std;
inline void in (int &x){
    x=0;char c=getchar();
    while (c<'0'||c>'9') c=getchar();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
}
inline void out (int x){
    if (x<0){putchar ('-');x=-x;}
    char s[25];int n=0;
    while (x||!n){s[n++]='0'+x%10;x/=10;}
    while (n--){putchar (s[n]);}puts ("");
}
int n,m,i,l,r,x,a[40005],b[40005],T[40005],maxx;
signed main (){
    in (n);in (m);
    for (i=1;i<=n;++i)
        in (a[i]),b[i]=a[i];
    sort (b+1,b+1+n);
    int cnt=unique (b+1,b+1+n)-b-1;
    for (i=1;i<=n;++i)
        a[i]=lower_bound (b+1,b+1+cnt,a[i])-b;
    while (m--){
        in (l);in (r);
        l=(l+b[x]-1)%n+1;r=(r+b[x]-1)%n+1;
        if (l>r) l^=r^=l^=r;
        for (i=l;i<=r-5;i+=6)
            ++T[a[i]],++T[a[i+1]],++T[a[i+2]],++T[a[i+3]],++T[a[i+4]],++T[a[i+5]];
        while (i<=r) ++T[a[i++]];
        for (i=1;i<=cnt;++i)
            maxx<T[i]?maxx=T[i],x=i:1;
        out (b[x]);maxx=0;
        for (i=l;i<=r-5;i+=6) 
            T[a[i]]=T[a[i+1]]=T[a[i+2]]=T[a[i+3]]=T[a[i+4]]=T[a[i+5]]=0;
        while (i<=r) T[a[i++]]=0;
    }
    return 0;
}

by liangbowen @ 2022-10-05 21:28:10

我草这么牛逼,把蒲公英暴力过了((


by dxy2020 @ 2022-10-05 21:29:56

@liangbowen 2e82s 时限跑过很正常啊


by Oops! @ 2022-10-05 21:32:56

40000*50000=2e9


by dxy2020 @ 2022-10-05 21:37:40

@Oops! 草,wssb


by fwhzqr @ 2022-10-05 21:41:15

@dxy2020 这么卷啊


by Magus @ 2022-10-05 21:44:48

@dxy2020 woc


by liangbowen @ 2022-10-05 22:30:55

@dxy2020 作为一道经典的分块,用暴力过掉是很离谱的事情,建议叫管理加强数据。


by _XHY20180718_ @ 2022-10-28 10:41:31

我不开O2也直接过了

将时间限制改到1s即可。


by lupengheyyds @ 2023-02-01 09:52:10

时限真的被改成1s了


by chang_an_1029 @ 2023-10-06 10:31:10

改为1s后还是过了(


|