Skip to content

Commit 77522ae

Browse files
authored
Merge pull request #1283 from AtCoder-NoviSteps/#1282
✨ Add agc to contest type (#1282)
2 parents ca7921c + 0aa56da commit 77522ae

File tree

6 files changed

+88
-3
lines changed

6 files changed

+88
-3
lines changed

prisma/ERD.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ TYPICAL90 TYPICAL90
2121
TESSOKU_BOOK TESSOKU_BOOK
2222
MATH_AND_ALGORITHM MATH_AND_ALGORITHM
2323
ARC ARC
24+
AGC AGC
2425
OTHERS OTHERS
2526
}
2627
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterEnum
2+
ALTER TYPE "ContestType" ADD VALUE 'AGC';

prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ enum ContestType {
216216
TESSOKU_BOOK // 競技プログラミングの鉄則
217217
MATH_AND_ALGORITHM // アルゴリズムと数学
218218
ARC // AtCoder Regular Contest
219+
AGC // AtCoder Grand Contest
219220
OTHERS // その他
220221
}
221222

src/lib/types/contest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const ContestType: { [key in ContestTypeOrigin]: key } = {
1414
TESSOKU_BOOK: 'TESSOKU_BOOK', // 競技プログラミングの鉄則
1515
MATH_AND_ALGORITHM: 'MATH_AND_ALGORITHM', // アルゴリズムと数学
1616
ARC: 'ARC', // AtCoder Regular Contest
17+
AGC: 'AGC', // AtCoder Grand Contest
1718
OTHERS: 'OTHERS',
1819
} as const;
1920

src/lib/utils/contest.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export const classifyContest = (contest_id: string) => {
1212
return ContestType.ARC;
1313
}
1414

15+
if (/^agc\d{3}$/.exec(contest_id)) {
16+
return ContestType.AGC;
17+
}
18+
1519
if (contest_id.startsWith('APG4b')) {
1620
return ContestType.APG4B;
1721
}
@@ -61,8 +65,8 @@ export const classifyContest = (contest_id: string) => {
6165
return null;
6266
};
6367

64-
// priority: 0 (High) - 12 (Low)
65-
// HACK: ARCの優先順位は暫定版
68+
// priority: 0 (High) - 13 (Low)
69+
// HACK: ARC、AGCの優先順位は暫定版
6670
//
6771
// See:
6872
// https://jsprimer.net/basic/map-and-set/
@@ -79,7 +83,8 @@ export const contestTypePriorities: Map<ContestType, number> = new Map([
7983
[ContestType.TESSOKU_BOOK, 9],
8084
[ContestType.MATH_AND_ALGORITHM, 10],
8185
[ContestType.ARC, 11],
82-
[ContestType.OTHERS, 12],
86+
[ContestType.AGC, 12],
87+
[ContestType.OTHERS, 13],
8388
]);
8489

8590
export function getContestPriority(contestId: string): number {

src/test/lib/utils/contest.test.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ describe('Contest', () => {
143143
});
144144
});
145145

146+
describe('when contest_id contains agc', () => {
147+
const testCases = [
148+
{ contestId: 'agc001', expected: ContestType.AGC },
149+
{ contestId: 'agc002', expected: ContestType.AGC },
150+
{ contestId: 'agc009', expected: ContestType.AGC },
151+
{ contestId: 'agc010', expected: ContestType.AGC },
152+
{ contestId: 'agc011', expected: ContestType.AGC },
153+
{ contestId: 'agc066', expected: ContestType.AGC },
154+
{ contestId: 'agc067', expected: ContestType.AGC },
155+
];
156+
157+
runTests('classifyContest', testCases, ({ contestId, expected }: TestCaseForContestType) => {
158+
expect(classifyContest(contestId)).toEqual(expected);
159+
});
160+
});
146161
describe('when contest_id contains chokudai_S', () => {
147162
const testCases = [
148163
{ contestId: 'chokudai_S001', expected: ContestType.OTHERS },
@@ -296,6 +311,26 @@ describe('Contest', () => {
296311
);
297312
});
298313

314+
describe('when contest_id contains agc', () => {
315+
const testCases = [
316+
{ contestId: 'agc001', expected: ContestType.AGC },
317+
{ contestId: 'agc002', expected: ContestType.AGC },
318+
{ contestId: 'agc009', expected: ContestType.AGC },
319+
{ contestId: 'agc010', expected: ContestType.AGC },
320+
{ contestId: 'agc011', expected: ContestType.AGC },
321+
{ contestId: 'agc066', expected: ContestType.AGC },
322+
{ contestId: 'agc067', expected: ContestType.AGC },
323+
];
324+
325+
runTests(
326+
'getContestPriority',
327+
testCases,
328+
({ contestId, expected }: TestCaseForContestType) => {
329+
expect(getContestPriority(contestId)).toEqual(contestTypePriorities.get(expected));
330+
},
331+
);
332+
});
333+
299334
describe('when contest_id contains chokudai_S', () => {
300335
const testCases = [
301336
{ contestId: 'chokudai_S001', expected: ContestType.OTHERS },
@@ -470,6 +505,26 @@ describe('Contest', () => {
470505
);
471506
});
472507

508+
describe('when contest_id contains agc', () => {
509+
const testCases = [
510+
{ contestId: 'agc001', expected: 'AGC001' },
511+
{ contestId: 'agc002', expected: 'AGC002' },
512+
{ contestId: 'agc009', expected: 'AGC009' },
513+
{ contestId: 'agc010', expected: 'AGC010' },
514+
{ contestId: 'agc011', expected: 'AGC011' },
515+
{ contestId: 'agc066', expected: 'AGC066' },
516+
{ contestId: 'agc067', expected: 'AGC067' },
517+
];
518+
519+
runTests(
520+
'getContestNameLabel',
521+
testCases,
522+
({ contestId, expected }: TestCaseForContestNameLabel) => {
523+
expect(getContestNameLabel(contestId)).toEqual(expected);
524+
},
525+
);
526+
});
527+
473528
describe('when contest_id contains chokudai_S', () => {
474529
const testCases = [
475530
{ contestId: 'chokudai_S001', expected: 'Chokudai SpeedRun 001' },
@@ -680,6 +735,26 @@ describe('Contest', () => {
680735
);
681736
});
682737

738+
describe('when contest_id contains agc', () => {
739+
const testCases = [
740+
{ contestId: 'agc001', taskTableIndex: 'A', expected: 'AGC001 - A' },
741+
{ contestId: 'agc002', taskTableIndex: 'B', expected: 'AGC002 - B' },
742+
{ contestId: 'agc009', taskTableIndex: 'C', expected: 'AGC009 - C' },
743+
{ contestId: 'agc010', taskTableIndex: 'D', expected: 'AGC010 - D' },
744+
{ contestId: 'agc011', taskTableIndex: 'E', expected: 'AGC011 - E' },
745+
{ contestId: 'agc066', taskTableIndex: 'F', expected: 'AGC066 - F' },
746+
{ contestId: 'agc067', taskTableIndex: 'E', expected: 'AGC067 - E' },
747+
];
748+
749+
runTests(
750+
'addContestNameToTaskIndex',
751+
testCases,
752+
({ contestId, taskTableIndex, expected }: TestCaseForContestNameAndTaskIndex) => {
753+
expect(addContestNameToTaskIndex(contestId, taskTableIndex)).toEqual(expected);
754+
},
755+
);
756+
});
757+
683758
function runTests(
684759
testName: string,
685760
testCases: TestCasesForContestNameAndTaskIndex,

0 commit comments

Comments
 (0)