Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

生成小规模随机测试数据以及对应答案的脚本, 助你解决WA~

Posted by lddlinan at 2020-04-29 10:51:52 on Problem 3467
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator