应该没有人和我一样暴力的时候*2吧(应该是平方)
auto 修改的时候要用 auto&。
卡常小建议:
fastio,特别是 fread/fwrite。附上板子:namespace FastIO{
static char buf[100000],*p1=buf,*p2=buf;
#define gc p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
inline int read() {int res=0,w=0; char c=gc; while (!isdigit(c)) c=gc; while (isdigit(c)) res=(res<<1)+(res<<3)+(c^48),c=gc; if (w) res=-res; return res;}
inline void write(int x) {static int sta[35],top=0; do {sta[top++]=x%10,x/=10;}while (x); while (top) putchar(sta[--top]+48); putchar('\n');}
inline void write(long long x) {static int sta[50],top=0; do {sta[top++]=x%10,x/=10;}while (x); while (top) putchar(sta[--top]+48); putchar('\n');}
};
using FastIO::read, FastIO::write;
理论上来说 buf 数组越大会越快,但实测开到 1e7 没差别。
不过似乎没什么用。
实测如下:
| 块长 | 时间 | 最大点 |
|---|---|---|
| 1 | 28.59s | 10.39s |
| 20 | 12.37s | 2.32s |
| 50 | 11.91s | 2.28s |
| 75 | 11.99s | 2.32s |
| 100 | 11.90s | 2.29s |
| 150 | 12.12s | 2.33s |
| 200 | 14.34s | 3.40s |
| 500 | 28.39s | 12.13s |
发现块长为 20−150 时表现较好。
此外,块长为 log2Vn 的表现也不错(13.11s/2.31s)。
这样的效率吊打链式。(链式就算存数访问也是不连续的)