FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges. The contest organizers adopted a new registration scheme this…
首先在串的末尾加上1000,然后进行归并,每次取字典序较小的那个后缀即可. 用hash+二分支持查询lcp,时间复杂度$O(n\log n)$. #include<cstdio> typedef long long ll; const int N=200010,P=31,D=1000173169; int n,m,i,j,k,pow[N],a[N],b[N],f[N],g[N]; inline void read(int&a){char c;while(!(((c=getchar())…