Hack!
查看原帖
Hack!
529780
zhangmj楼主2021/6/18 16:44

题解区@dingcx 大佬的题解中对于每个k=0都会重新Θ(n)\Theta(n)的算一遍.

所以如果m=n=2×105m=n=2\times 10^5, k1=k2==km=0k_1=k_2=\cdots=k_m=0.

它就会TLE.

所以应该在k=0k=0的时候也把答案记下来, 这样子才是时间复杂度正确的.

数据生成器:

#include<bits/stdc++.h>
using namespace std;

int main(){
	freopen("input.in", "r", stdin);
	int n = 2e5, m = 2e5;
	cout << n << ' ' << m << endl;
	for(int i = 1; i <= n; i ++)
		cout << 0 << ' ';
	cout << endl;
	for(int i = 1; i <= m; i ++)
		cout << 0 << endl;
	return 0;
}
2021/6/18 16:44
加载中...