Skip to content

✨ Add tasks (#1866) #1873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/lib/utils/contest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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なう',
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions src/test/lib/utils/test_cases/contest_name_and_task_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -510,6 +537,7 @@ const generateUniversityTestCases = (
};

const ALL_UNIVERSITY_TEST_DATA: UniversityContestsTestData = {
...KUPC_TEST_DATA,
...UTPC_TEST_DATA,
...TTPC_TEST_DATA,
...TUPC_TEST_DATA,
Expand Down
12 changes: 12 additions & 0 deletions src/test/lib/utils/test_cases/contest_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,21 @@ 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-
//
// See:
// https://kenkoooo.com/atcoder/resources/contests.json
const universityContestIds = [
'kupc2012',
'kupc2013',
'kupc2014',
'kupc2019',
'kupc2020',
'kupc2021',
'kupc2024',
'utpc2011',
'utpc2012',
'utpc2013',
Expand Down Expand Up @@ -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,
Expand Down
Loading