1
- import { ContestType } from '$lib/types/contest' ;
1
+ import { ContestType , type ContestPrefix } from '$lib/types/contest' ;
2
2
3
3
// See:
4
4
// https://github.com/kenkoooo/AtCoderProblems/blob/master/atcoder-problems-frontend/src/utils/ContestClassifier.ts
@@ -55,36 +55,15 @@ export const classifyContest = (contest_id: string) => {
55
55
return ContestType . MATH_AND_ALGORITHM ;
56
56
}
57
57
58
- // HACK: 2024年10月上旬時点では、以下のコンテストが該当。
59
- // Note: 対象コンテストが増えた場合は、判定条件を見直す必要がある。
60
- if ( contest_id === 'tenka1-2018' ) {
58
+ if ( arcLikePrefixes . has ( contest_id ) ) {
61
59
return ContestType . ARC_LIKE ;
62
60
}
63
61
64
- // ・CODE FESTIVAL 2017 qual
65
- // ・CODE FESTIVAL 2017 Final
66
- const prefixForAgcLike = [ 'code-festival-2017-qual' , 'cf17-final' ] ;
67
-
68
- if ( prefixForAgcLike . some ( ( prefix ) => contest_id . startsWith ( prefix ) ) ) {
62
+ if ( agcLikePrefixes . some ( ( prefix ) => contest_id . startsWith ( prefix ) ) ) {
69
63
return ContestType . AGC_LIKE ;
70
64
}
71
65
72
- // ・Chokudai SpeedRun
73
- // ・CODE FESTIVAL 2014 決勝
74
- // ・Donutsプロコンチャレンジ
75
- // ・MUJIN Programming Challenge 2016
76
- // ・COLOCON
77
- // ・GigaCode
78
- const prefixForOthers = [
79
- 'chokudai_S' ,
80
- 'code-festival-2014-final' ,
81
- 'donuts' ,
82
- 'mujin-pc-2016' ,
83
- 'colopl' ,
84
- 'gigacode' ,
85
- ] ;
86
-
87
- if ( prefixForOthers . some ( ( prefix ) => contest_id . startsWith ( prefix ) ) ) {
66
+ if ( atCoderOthersPrefixes . some ( ( prefix ) => contest_id . startsWith ( prefix ) ) ) {
88
67
return ContestType . OTHERS ;
89
68
}
90
69
@@ -99,18 +78,52 @@ export const classifyContest = (contest_id: string) => {
99
78
return null ;
100
79
} ;
101
80
102
- export const AOJ_COURSES = {
81
+ // HACK: As of early November 2024, the following contests are applicable.
82
+ // Note: The classification logic may need to be revised when new contests are added.
83
+ const ARC_LIKE : ContestPrefix = {
84
+ 'tenka1-2018' : 'Tenka1 Programmer Contest 2018' ,
85
+ } as const ;
86
+ const arcLikePrefixes = new Set ( getContestPrefixes ( ARC_LIKE ) ) ;
87
+
88
+ const AGC_LIKE : ContestPrefix = {
89
+ 'code-festival-2016-qual' : 'CODE FESTIVAL 2016 qual' ,
90
+ 'code-festival-2017-qual' : 'CODE FESTIVAL 2017 qual' ,
91
+ 'cf17-final' : 'CODE FESTIVAL 2017 final' ,
92
+ } as const ;
93
+ const agcLikePrefixes = getContestPrefixes ( AGC_LIKE ) ;
94
+
95
+ const ATCODER_OTHERS : ContestPrefix = {
96
+ chokudai_S : 'Chokudai SpeedRun' ,
97
+ 'code-festival-2014-final' : 'Code Festival 2014 決勝' ,
98
+ donuts : 'Donutsプロコンチャレンジ' ,
99
+ 'mujin-pc-2016' : 'Mujin Programming Challenge 2016' ,
100
+ 'tenka1-2016-final' : '天下一プログラマーコンテスト2016本戦' ,
101
+ colopl : 'COLOCON' ,
102
+ gigacode : 'GigaCode' ,
103
+ } as const ;
104
+ const atCoderOthersPrefixes = getContestPrefixes ( ATCODER_OTHERS ) ;
105
+
106
+ // AIZU ONLINE JUDGE AOJ Courses
107
+ export const AOJ_COURSES : ContestPrefix = {
103
108
ITP1 : 'プログラミング入門' ,
104
109
ALDS1 : 'アルゴリズムとデータ構造入門' ,
105
110
ITP2 : 'プログラミング応用' ,
106
111
DPL : '組み合わせ最適化' ,
107
112
} as const ;
108
113
114
+ export function getPrefixForAojCourses ( ) {
115
+ return getContestPrefixes ( AOJ_COURSES ) ;
116
+ }
117
+
109
118
const aojCoursePrefixes = new Set ( getPrefixForAojCourses ( ) ) ; // For O(1) lookups
110
119
111
- // AIZU ONLINE JUDGE AOJ Courses
112
- export function getPrefixForAojCourses ( ) {
113
- return Object . keys ( AOJ_COURSES ) ;
120
+ /**
121
+ * Extracts contest prefixes (keys) from a contest prefix object.
122
+ * @param contestPrefixes - Object mapping contest IDs to their display names
123
+ * @returns Array of contest prefix strings
124
+ */
125
+ export function getContestPrefixes ( contestPrefixes : Record < string , string > ) {
126
+ return Object . keys ( contestPrefixes ) ;
114
127
}
115
128
116
129
// priority: 0 (High) - 18 (Low)
0 commit comments