推荐一款不错的数据生成器:CYaRon,一个基于Python的测试数据生成库。能够生成一部分信息竞赛中需要的数据,操作简单,易入门。

项目地址

部署及基本语法

详见 luogu 官方文档

常用模板

  1. 数据生成

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    from cyaron import *

    _n = ati([1, 7, 50, 1E4])
    _m = ati([1, 11, 100, 1E4])

    for i in range(1, 4):
    io = IO(file_prefix = "name", data_id = i)

    n = _n[i]
    m = _m[i]
    s = randint(1, n)
    t = randint(1, n)
    graph = Graph.graph(n, m, weight_limit = 5)

    io.input_writeln(n, m, s, t)
    io.input_writeln(graph)
    io.output_gen("std")
  2. 对拍

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    from cyaron import *

    for i in range(1000):
    print("Case:{0}".format(i))
    iostd = IO("name.in", "name.stdout")
    iotest = IO("name.in", "name.testout")

    n = randint(1, 3)
    m = randint(n - 1, 5)
    s = randint(1, n)
    t = randint(1, n)
    graph = Graph.UDAG(n, m, weight_limit = 10)

    iostd.input_writeln(n, m, s, t)
    iostd.input_writeln(graph.to_str(shuffle = True))

    iostd.output_gen("./std")
    iotest.output_gen("./test")
    Compare.output("name.testout", std = "name.stdout")