-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare_codes.py
More file actions
85 lines (74 loc) · 1.98 KB
/
prepare_codes.py
File metadata and controls
85 lines (74 loc) · 1.98 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import argparse
from pathlib import Path
from typing import List
template_code = """
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1 << 30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
os << p.first << " " << p.second;
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
for (int i = 0; i < (int)v.size(); i++)
os << v[i] << (i + 1 != v.size() ? " " : "");
return os;
}
void solve()
{
}
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
}
"""
def main(args: argparse.Namespace):
dir: Path = args.dir
problems: List[str] = args.problems
dir.mkdir(parents=True, exist_ok=True)
for problem in problems:
problem_path: Path = dir / problem
if problem_path.with_suffix(".cpp").exists():
print(f"{problem} already exists")
continue
problem_path.with_suffix(".cpp").write_text(template_code.lstrip("\n"))
list_files = [str(file) for file in dir.glob("*.cpp")]
print(f"Created files: {list_files}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Prepare code for the contest")
parser.add_argument(
"--dir", type=Path, default=Path().cwd(), help="Directory to store the codes",
)
parser.add_argument(
"--problems",
nargs="+",
default=["a", "b", "c", "d", "e", "f"],
help="List of problems to prepare",
)
args = parser.parse_args()
main(args)