数据生成器

数据生成器

版权声明!

本数据生成器由长春吉大附中实验学校衣然@Yirannn同窗自主开发。开发者拥有并保留本产品的所有权利。对于任何未经其本人容许而将本产品用于任何盈利或非盈利用途的行为,以及未注明版权的转载,开发者保留追究其法律责任的权利。python

数据生成器:

# ~/usr/bin/python3
# A Simple Data Generator For OIers By Yirannn 
# Made By Python
# Have Fun to Generator Data !

import os
import random
import sys
from time import time
# 预处理
FErr = open("Err.Log", "w")
sys.stderr = FErr
# 输入提示
print("请按以下格式补充留在本文件夹的文件")
print("请注意 为保证数据生成随机,本程序会对main函数传一个参数, 请使用该参数做为随机种子")
print("输入数据生成器 : Gen_1.cpp")
print("输出数据生成器 : Std_1.cpp")
print("输出数据对拍器 : Std_2.cpp")
print("本程序编译命令 : g++ %s.cpp -o %s.exe -O2 -std=c++11")
Problem_Name = input("请输入题目英文名,本程序将在程序根目录下建立该名字文件夹并导出数据\n")
while(Problem_Name == "") :
    Problem_Name = input("请输入题目英文名,本程序将在程序根目录下建立该名字文件夹并导出数据\n")
print("若是须要 Spj 请把Spj程序命名为 'Spj.cpp' 并放在根目录下")
Need_Spj = input("是否须要Special_Judge程序? 是请输入 1 不然输入 0")
# 系统识别
Operator_System = 2 if os.name == "nt" else 1
Clear_Screen = ""
Test = ""
Exist = os.path.exists(Problem_Name)
Error = False
if Operator_System == 1 :
    Clear_Screen = "clear"
    Test = "diff "
    if (Exist != True) :
        os.system("mkdir " + "\"" + Problem_Name + "\"")
else :
    Clear_Screen = "cls"
    Test = "fc "
    if (Exist != True) :
        os.system("md " + Problem_Name)
if Need_Spj == 1 :
    os.system("g++ spj.cpp -o spj -O2")
    Test = "Spj "

# 数据生成
while(True) :
    while True :
        try : 
            From, End = input("请输入数据编号范围 生成完毕请输入两个0\n").split()
            break
        except :
            print("请输入两个正常的数字!")
    os.system(Clear_Screen)
    From = int(From)
    End = int(End)
    if End == 0 : 
        break
    os.system("g++ data.cpp -o Gen_1.exe -O2 -Wl,--stack=40000000")
    os.system("g++ test.cpp -o Std_1.exe -O2")
    Execute = "./" if Operator_System == 1 else  ""
    for i in range(From, End+1) : 
        Num = str(i)
        RandomSeed = str(random.randint(1, 100000000))
        os.system(Execute + "Gen_1.exe " + Num + " " + RandomSeed + " > " + Problem_Name + "/" + Num + ".in")
        Start_Time = time()
        os.system(Execute + "Std_1.exe < " + Problem_Name + "/" + Num + ".in > " + Problem_Name + "/" + Num + ".out")
        OverA_Time = time()
        # os.system(Execute + "Std_2.exe < " + Problem_Name + "/" + Num + ".in > " + Problem_Name + "/" + Num + ".ans")
        # OverB_Time = time()
        # Jud = os.system(Test + Problem_Name + "/" + Num + ".out " + Problem_Name + "/" + Num + ".ans")
        # if Jud != 0 :
        #   RandomSeed = str(random.randint(1, 100000000))
        #   print("WA On Gen", Num)
        #   print("正在尝试从新生成一组数据,请稍候")
        #   os.system(Execute + "Gen_1.exe " + Num + " "+ RandomSeed + " > " + Problem_Name + "/" + Num + ".in")
        #   os.system(Execute + "Std_1.exe < " + Problem_Name + "/" + Num + ".in > " + Problem_Name + "/" + Num + ".out")
        #   os.system(Execute + "Std_2.exe < " + Problem_Name + "/" + Num + ".in > " + Problem_Name + "/" + Num + ".ans")
        #   Jud = os.system(Test + Problem_Name + "/" + Num + ".out " + Problem_Name + "/" + Num + ".ans")
        #   if Jud != 0 :
        #       print("您的数据生成器或者标程可能出问题了,请修改后再次生成!")
        #       Error = True
        #       sys.exit(1)
        # else :
        #   print("AC On Gen ", Num, "Runtime : Std_1 : %f && Std_2 : %f" %(OverA_Time - Start_Time, OverB_Time - OverA_Time))
        # os.system("rm " + Problem_Name + "/" + Num + ".ans")
        # if(Error) :
        #   break

# 感谢使用
os.system("del Gen_1.exe")
os.system("del Std_1.exe")
Exist = os.path.exists("Err.log")
close(FErr)
if(Exist) :
    os.system("rm Err.log")

使用注意:

数据生成器是python源文件。请使用者自行安装python后使用python运行。并按其指示操做。c++

替学长感谢你们的使用和支持~dom