注意 multiset.count() 是 O(n) 的复杂度而非 O(logn)。题目保证加入的数集合中没有,但是题解普遍做法是先对 C 取模后再加入,这样导致了 xmodC 会有很多个。
数据生成器:
#include <bits/stdc++.h>
using namespace std;
namespace Le0{
int main(){
int n=500000;
cout<<n<<" 1\n";
for(int i=1;i<=n;i++){
cout<<1<<" "<<i<<"\n";
}
return 0;
}
}
int main(){
freopen("1.in","w",stdout);
ios::sync_with_stdio(0),cin.tie(0);
return Le0::main();
}
以下题解本地测试均 TLE。
Owen_codeisking
sto_5k_orz
Terac
Marshadow
RainsAFO