diff --git a/src/lib/utils/contest.ts b/src/lib/utils/contest.ts index fcbad69cd..fd7d3ae23 100644 --- a/src/lib/utils/contest.ts +++ b/src/lib/utils/contest.ts @@ -118,13 +118,14 @@ const AGC_LIKE: ContestPrefix = { } as const; const agcLikePrefixes = getContestPrefixes(AGC_LIKE); -// HACK: As of November 2024, UTPC, TTPC and TUPC are included. +// HACK: As of March 2025, KUPC, UTPC, TTPC and TUPC are included. // More university contests may be added in the future. /** * Maps university contest ID prefixes to their display names. * * @example * { + * kupc: 'KUPC' // Kyoto University Programming Contest * utpc: 'UTPC' // University of Tokyo Programming Contest * ttpc: 'TTPC' // Tokyo Institute of Technology Programming Contest * tupc: 'TUPC' // Tohoku University Programming Contest @@ -137,6 +138,7 @@ const agcLikePrefixes = getContestPrefixes(AGC_LIKE); * 3. Ensure prefix doesn't conflict with existing contest types */ const ATCODER_UNIVERSITIES: ContestPrefix = { + kupc: 'KUPC', utpc: 'UTPC', ttpc: 'TTPC', tupc: 'TUPC', @@ -164,6 +166,7 @@ const ATCODER_OTHERS: ContestPrefix = { chokudai_S: 'Chokudai SpeedRun', 'code-festival-2014-qualb': 'Code Festival 2014 予選 B', 'code-festival-2014-final': 'Code Festival 2014 決勝', + 'code-festival-2015-morning-middle': 'CODE FESTIVAL 2015 あさぷろ Middle', 'code-thanks-festival': 'CODE THANKS FESTIVAL', donuts: 'Donutsプロコンチャレンジ', indeednow: 'Indeedなう', @@ -280,16 +283,17 @@ const regexForAxc = /^(abc|arc|agc)(\d{3})/i; * Regular expression to match AtCoder University contest identifiers. * * The pattern matches strings that: - * - Start with either "ut", "tt", or "tu" + * - Start with either "ku", "ut", "tt", or "tu" * - Followed by "pc" * - End with exactly year (four digits) * * Example matches: + * - "kupc2024" * - "utpc2014" * - "ttpc2022" * - "tupc2023" */ -const regexForAtCoderUniversity = /^(ut|tt|tu)(pc)(\d{4})/i; +const regexForAtCoderUniversity = /^(ku|ut|tt|tu)(pc)(\d{4})/i; export const getContestNameLabel = (contestId: string) => { // AtCoder diff --git a/src/test/lib/utils/test_cases/contest_name_and_task_index.ts b/src/test/lib/utils/test_cases/contest_name_and_task_index.ts index fe46a93d7..2b764fd85 100644 --- a/src/test/lib/utils/test_cases/contest_name_and_task_index.ts +++ b/src/test/lib/utils/test_cases/contest_name_and_task_index.ts @@ -412,12 +412,39 @@ interface UniversityContestsTestData { } // Note: +// KUPC contests on AtCoder: 2012-2021 and 2024- (not held during 2022-2023) // UTPC contests on AtCoder: 2011-2014 and 2020-2023 (not held during 2015-2019) // TTPC contests on AtCoder: 2015, 2019, 2022- // TUPC contests on AtCoder: 2022- // // See: // https://kenkoooo.com/atcoder/resources/contests.json +type KupcYear = '2012' | '2013' | '2014' | '2019' | '2020' | '2021' | '2024'; +type KupcTaskPatterns = { + [K in KupcYear]: string[]; +}; + +const KUPC_TASK_PATTERNS: KupcTaskPatterns = { + '2012': ['A', 'B', 'C', 'G', 'H', 'I'], + '2013': ['A', 'B', 'C', 'I', 'J', 'K'], + '2014': ['A', 'B', 'C', 'J', 'K', 'L'], + '2019': ['A', 'B', 'C', 'J', 'K', 'L'], + '2020': ['A', 'B', 'C', 'K', 'L', 'M'], + '2021': ['A', 'B', 'C', 'K', 'L', 'M'], + '2024': ['A', 'B', 'C', 'N', 'O', 'P'], +}; + +const KUPC_YEARS = [2012, 2013, 2014, 2019, 2020, 2021, 2024]; +const KUPC_TEST_DATA: UniversityContestsTestData = Object.fromEntries( + KUPC_YEARS.map((year) => [ + `kupc${year}`, + { + contestId: `kupc${year}`, + tasks: KUPC_TASK_PATTERNS[year.toString() as keyof KupcTaskPatterns], + }, + ]), +) as UniversityContestsTestData; + type UtpcTaskPatterns = { '2011-2014': string[]; '2020': string[]; @@ -510,6 +537,7 @@ const generateUniversityTestCases = ( }; const ALL_UNIVERSITY_TEST_DATA: UniversityContestsTestData = { + ...KUPC_TEST_DATA, ...UTPC_TEST_DATA, ...TTPC_TEST_DATA, ...TUPC_TEST_DATA, diff --git a/src/test/lib/utils/test_cases/contest_type.ts b/src/test/lib/utils/test_cases/contest_type.ts index c6f9274ec..8e0c6eaf0 100644 --- a/src/test/lib/utils/test_cases/contest_type.ts +++ b/src/test/lib/utils/test_cases/contest_type.ts @@ -256,6 +256,7 @@ export const agcLike = [ ]; // Note: +// KUPC contests on AtCoder: 2012-2021 and 2024- (not held during 2022-2023) // UTPC contests on AtCoder: 2011-2014 and 2020-2023 (not held during 2015-2019) // TTPC contests on AtCoder: 2015, 2019, 2022- // TUPC contests on AtCoder: 2022- @@ -263,6 +264,13 @@ export const agcLike = [ // See: // https://kenkoooo.com/atcoder/resources/contests.json const universityContestIds = [ + 'kupc2012', + 'kupc2013', + 'kupc2014', + 'kupc2019', + 'kupc2020', + 'kupc2021', + 'kupc2024', 'utpc2011', 'utpc2012', 'utpc2013', @@ -303,6 +311,10 @@ export const atCoderOthers = [ contestId: 'code-festival-2014-final', expected: ContestType.OTHERS, }), + createTestCaseForContestType('CODE FESTIVAL 2015 あさぷろ Middle')({ + contestId: 'code-festival-2015-morning-middle', + expected: ContestType.OTHERS, + }), createTestCaseForContestType('CODE THANKS FESTIVAL 2017')({ contestId: 'code-thanks-festival-2017', expected: ContestType.OTHERS,