tarjan缩点,然后树形dp一下可解。重点是重边的处理。
1 /* 2242 */ 2 #include 3 #include 4 #include 5 #include
数据生成器。
1 import sys 2 import string 3 from random import randint 4 5 6 def GenData(fileName): 7 with open(fileName, "w") as fout: 8 t = 10 9 for tt in xrange(t):10 n = randint(100, 200)11 m = randint(n/10, n+n/10)12 fout.write("%d %d\n" % (n, m))13 dataList = []14 for i in xrange(n):15 x = randint(0, 1000)16 dataList.append(x)17 fout.write(" ".join(map(str, dataList)) + "\n")18 for i in xrange(m):19 a = randint(0, n)20 b = randint(0, n)21 fout.write("%d %d\n" % (a, b))22 23 24 def MovData(srcFileName, desFileName):25 with open(srcFileName, "r") as fin:26 lines = fin.readlines()27 with open(desFileName, "w") as fout:28 fout.write("".join(lines))29 30 31 def CompData():32 print "comp"33 srcFileName = "F:\Qt_prj\hdoj\data.out"34 desFileName = "F:\workspace\cpp_hdoj\data.out"35 srcLines = []36 desLines = []37 with open(srcFileName, "r") as fin:38 srcLines = fin.readlines()39 with open(desFileName, "r") as fin:40 desLines = fin.readlines()41 n = min(len(srcLines), len(desLines))-142 for i in xrange(n):43 ans2 = int(desLines[i])44 ans1 = int(srcLines[i])45 if ans1 > ans2:46 print "%d: wrong" % i47 48 49 if __name__ == "__main__":50 srcFileName = "F:\Qt_prj\hdoj\data.in"51 desFileName = "F:\workspace\cpp_hdoj\data.in"52 GenData(srcFileName)53 MovData(srcFileName, desFileName)54 55