-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
51 lines (38 loc) · 1.49 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os,sys
import shutil
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-J','--judge', help='judge name',default = 'codeforces')
parser.add_argument('-C','--contest_id', help = 'contest id', default = None)
parser.add_argument('-P','--problem_name', help = 'problem name', default = None)
parser.add_argument('-D','--create_directory', default = False, action = 'store_true')
args = parser.parse_args()
path = args.judge
if args.contest_id is None and args.problem_name is None:
print('no data')
exit(0)
if args.contest_id is not None:
path = os.path.join(path, args.contest_id)
if args.create_directory and args.problem_name:
path = os.path.join(path, args.problem_name)
if not os.path.exists(path):
os.makedirs(path)
templates_path = '../workspace/cp-library/templates/'
for f in 'template.cpp','tester.py':
shutil.copy(os.path.join(templates_path, f),path)
os.system('touch ' + os.path.join(path, 'in.in'))
if any([judge in path for judge in ('codeforces', 'atcoder')]):
n = 6
if "codeforces" in path and int(args.contest_id) >= 10**5:
n = 13
for k in range(n):
c = chr(ord('A') + k)
to = os.path.join(path,c + '.cpp')
if not os.path.exists(to):
shutil.copy(os.path.join(path,'template.cpp'), to)
os.remove(os.path.join(path,'template.cpp'))
elif args.problem_name is not None:
to = os.path.join(path,args.problem_name + '.cpp')
if not os.path.exists(to):
shutil.copy(os.path.join(path,'template.cpp'), to)
os.remove(os.path.join(path,'template.cpp'))