save_code

#!/usr/bin/python3
import sys,os,random
os.system("mkdir alldata")
A=[]
for root,dirs,file in os.walk("."):
	if root[2:9]=="alldata" or root==".":continue
	for i in file:
		if i[-4:]==".ans" or i[-3:]==".in" or  i[-4:]==".out":
			A.append([root,i])
			print(i)
A.sort()
n_subtasks=1
for i in range(1,len(A)):
	if A[i][0]!=A[i-1][0]:n_subtasks+=1
ID=0
SID=0
conf=open("alldata/problem.conf","w")
print("n_tests %d\n"%(len(A)//2),
"n_ex_tests 0\n"
"n_sample_tests 0\n"
"input_pre data\n"
"input_suf in\n"
"output_pre data\n"
"output_suf out\n"
"time_limit 1?\n"
"memory_limit 512?\n"
"output_limit 64\n"
"use_builtin_judger on\n"
"use_builtin_checker wcmp?\n"
"n_subtasks %d"%n_subtasks,
file=conf,sep='')
for i in range(0,len(A),2):
	ID+=1
	root=A[i][0]
	filein=A[i][1]
	fileout=A[i+1][1]
	if A[i][1][-4:]==".ans":filein,fileout=fileout,filein
	os.system("cp %s/%s alldata/data%s"%(root,filein,str(ID)+".in"))
	os.system("cp %s/%s alldata/data%s"%(root,fileout,str(ID)+".out"))
	if i==len(A)-2 or A[i+2][0]!=A[i][0]:
		SID+=1
		print("subtask_end_%d"%SID,ID,file=conf)
		print("subtask_score_%d "%SID,file=conf)
os.system("gedit alldata/problem.conf&")
posted @ 2020-12-02 11:39  菜狗xzz  阅读(216)  评论(0编辑  收藏  举报