Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
块状链表终于过了,调试得想吐,写了个生成随机数据的脚本, 对WA有很大帮助# gen.py from random import randint acts = ["ADD", "REVERSE", "REVOLVE", "INSERT", "DELETE", "MIN"] for i in range(100): filein = open("%03d" % i, "w"); fileout = open("%03d.a" % i, "w"); n = randint(0, 10000) filein.write(str(n)+'\n') vs = [randint(-10000, 10000) for _ in range(n)] filein.write("\n".join([str(v) for v in vs])+"\n") m = randint(1000, 2000) filein.write(str(m)+'\n') r = [] for _ in range(m): a = randint(0, 5) if len(vs)==0: a=3 if a==0: x = randint(1, len(vs)) y = randint(x, len(vs)) d = randint(-1000, 1000) filein.write("%s %d %d %d\n" % (acts[a], x, y, d)) k=x-1; while k<y: vs[k] += d k+=1 elif a==1: x = randint(1, len(vs)) y = randint(x, len(vs)) filein.write("%s %d %d\n" % (acts[a], x, y)) x-=1 y-=1 while x<=y: vs[x], vs[y] = vs[y], vs[x] x+=1 y-=1 elif a==2: x = randint(1, len(vs)) y = randint(x, len(vs)) t = randint(-1000, 1000) filein.write("%s %d %d %d\n" % (acts[a], x, y, t)) n = y-x+1 t %=n if t<0: t+=n x-=1 vs[x:x+t], vs[x+t:y] = vs[y-t:y], vs[x:y-t] elif a==3: x = randint(0, len(vs)) v = randint(-1000, 1000) filein.write("%s %d %d\n" % (acts[a], x, v)) vs.insert(x, v) elif a==4: x = randint(1, len(vs)) filein.write("%s %d\n" % (acts[a], x)) del vs[x-1] else: x = randint(1, len(vs)) y = randint(x, len(vs)) filein.write("%s %d %d\n" % (acts[a], x, y)) m = vs[x-1] while x<y: if m>vs[x]: m=vs[x] x+=1 r.append(str(m)) fileout.write("\n".join(r)+"\n"); filein.close() fileout.close() ############################### # time for i in {000..099}; do ./a.out < ${i} > o1; git diff ${i}.a o1; echo "---${i}---"; done Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator