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~from random import randint def gen(ii): n, m, c, q = randint(1,50), randint(1,50), 3, randint(1, 1000) r = [] oo = [] r.append(str(n)) r.append(str(m)) r.append(str(c)) r.append(str(q)) r.append("\n") mm = [None]*n def count(c, n, m): rc = 0; for i in range(n): for j in range(m): if mm[i][j]!=c: continue k=1 while True: if i-k<0 or i+k>=n or j-k<0 or j+k>=m: break if mm[i-k][j]!=c: break if mm[i+k][j]!=c: break if mm[i][j-k]!=c: break if mm[i][j+k]!=c: break k+=1 rc += (k-1) return rc for i in range(n): mm[i] = [randint(1, c) for _ in range(m)] for v in mm[i]: r.append(str(v)) r.append("\n") for i in range(q): f = randint(0,2) if f==0: r.append('Q') x = randint(1, c) r.append(str(x)) r.append("\n") oo.append(str(count(x, n, m))) else: x, y, k = randint(1, n), randint(1, m), randint(1, c) r.append('C') r.append(str(x)) r.append(str(y)) r.append(str(k)) r.append("\n") mm[x-1][y-1]=k with open("%03d"%ii, "w") as f: f.write(" ".join(r)); oo.append("") with open("%03d.a"%ii, "w") as f: f.write("\n".join(oo)); for i in range(100): gen(i) # for i in {001..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