-
-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathContestClassifier.ts
More file actions
115 lines (105 loc) · 2.67 KB
/
ContestClassifier.ts
File metadata and controls
115 lines (105 loc) · 2.67 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import Contest from "../interfaces/Contest";
import { RatedTargetType, getRatedTarget } from "../components/ContestLink";
export const ContestCategories = [
"ABC",
"ARC",
"AGC",
"ABC-Like",
"ARC-Like",
"AGC-Like",
"PAST",
"JOI",
"JAG",
"AHC",
"Marathon",
"Other Sponsored",
"Other Contests",
] as const;
export type ContestCategory = typeof ContestCategories[number];
export const AGC_001_START = 1468670400;
export const isRatedContest = (
contest: Contest,
problemCount: number
): boolean => {
return (
contest.rate_change !== "-" &&
contest.start_epoch_second >= AGC_001_START &&
problemCount >= 2
);
};
const classifyOtherRatedContest = (contest: Contest): ContestCategory => {
const rated = getRatedTarget(contest);
if (rated === RatedTargetType.All) {
return "AGC-Like";
}
if (rated < 2000) {
return "ABC-Like";
}
return "ARC-Like";
};
export const classifyContest = (
contest: Contest,
problemCount = 100 // TODO: This function can not classify a non-AHC heuristic contest with this default parameter.
): ContestCategory => {
if (/^abc\d{3}$/.exec(contest.id)) {
return "ABC";
}
if (/^arc\d{3}$/.exec(contest.id)) {
return "ARC";
}
if (/^agc\d{3}$/.exec(contest.id)) {
return "AGC";
}
if (
/^ahc\d{3}$/.exec(contest.id) ||
["toyota2023summer-final"].includes(contest.id)
) {
return "AHC";
}
if (isRatedContest(contest, problemCount)) {
return classifyOtherRatedContest(contest);
}
if (contest.id.startsWith("past")) {
return "PAST";
}
if (contest.id.startsWith("joi")) {
return "JOI";
}
if (/^(jag|JAG)/.exec(contest.id)) {
return "JAG";
}
if (
/(^Chokudai Contest|ハーフマラソン|HACK TO THE FUTURE|Asprova|Heuristics Contest)/.exec(
contest.title
) ||
/(^future-meets-you-contest|^hokudai-hitachi|^toyota-hc)/.exec(
contest.id
) ||
[
"toyota2023summer-final-open",
"genocon2021",
"stage0-2021",
"caddi2019",
"pakencamp-2019-day2",
"kuronekoyamato-contest2019",
"wn2017_1",
].includes(contest.id)
) {
return "Marathon";
}
if (
/(ドワンゴ|^Mujin|SoundHound|^codeFlyer|^COLOCON|みんなのプロコン|CODE THANKS FESTIVAL)/i.exec(
contest.title
) ||
/(CODE FESTIVAL|^DISCO|日本最強プログラマー学生選手権|全国統一プログラミング王|Indeed)/i.exec(
contest.title
) ||
/(^Donuts|^dwango|^DigitalArts|^Code Formula|天下一プログラマーコンテスト|^Toyota)/i.exec(
contest.title
) ||
/(^Recruit|^CodeQUEEN)/i.exec(contest.title)
) {
return "Other Sponsored";
}
return "Other Contests";
};