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-05-02 14:07:55 on Problem 3376
# 注意结果真的要用 long long 保存, 不然WA
from random import randint

a="".join([chr(ord('a')+i) for i in range(26)])

def gen(ii):
    n = randint(1, 1000)
    ss = []
    oh = open("%03d"%ii, "w");
    oo = open("%03d.a"%ii, "w");
    oh.write(str(n)+'\n');
    for i in range(n):
        c = randint(0, 10);
        s = "".join([a[randint(0, 3)] for _ in range(c)])
        oh.write(str(c)+" "+s+'\n');
        ss.append(s)
    rc=0;
    for sa in ss:
        for sb in ss:
            s = sa+sb;
            i, j=0, len(s)-1
            m = 1
            while i<j:
                if s[i]!=s[j]:
                    m=0;
                    break;
                i+=1
                j-=1
            rc += m
    oo.write(str(rc)+'\n');
    oh.close();
    oo.close();

for i in range(100):
    gen(i)


    

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