后缀数组加二分可解。
1 /* 3553 */ 2 #include 3 #include 4 #include 5 #include
数据生成器。
1 from random import randint, shuffle 2 import shutil 3 import string 4 5 6 def GenDataIn(): 7 with open("data.in", "w") as fout: 8 t = 20 9 bound = 10**310 uc = list(string.uppercase)11 fout.write("%d\n" % (t))12 for tt in xrange(t):13 n = randint(100, 200)14 kth = randint(1, n*(n+1)/2)15 line = ""16 for i in xrange(n):17 idx = randint(0, 25)18 line += uc[idx]19 fout.write("%s %d\n" % (line, kth))20 21 def MovDataIn():22 desFileName = "F:\eclipse_prj\workspace\hdoj\data.in"23 shutil.copyfile("data.in", desFileName)24 25 26 if __name__ == "__main__":27 GenDataIn()28 MovDataIn()