1
1
import {
2
2
Button ,
3
+ ButtonGroup ,
3
4
Col ,
4
5
DropdownItem ,
5
6
DropdownMenu ,
@@ -15,11 +16,13 @@ import {
15
16
} from "reactstrap" ;
16
17
import React , { useState } from "react" ;
17
18
import {
19
+ useContests ,
18
20
useMultipleUserSubmissions ,
19
21
useProblemModelMap ,
20
22
useProblems ,
21
23
} from "../api/APIClient" ;
22
24
import Problem from "../interfaces/Problem" ;
25
+ import Contest from "../interfaces/Contest" ;
23
26
import { shuffleArray } from "../utils" ;
24
27
import {
25
28
ExcludeOption ,
@@ -29,6 +32,7 @@ import {
29
32
getLastSolvedTimeMap ,
30
33
getMaximumExcludeElapsedSecond ,
31
34
} from "../utils/LastSolvedTime" ;
35
+ import { classifyContest } from "../utils/ContestClassifier" ;
32
36
import { isProblemModelWithDifficultyModel } from "../interfaces/ProblemModel" ;
33
37
34
38
interface Props {
@@ -90,13 +94,30 @@ export const ProblemSetGenerator: React.FC<Props> = (props) => {
90
94
) ;
91
95
const [ excludeExperimental , setExcludeExperimental ] = useState ( false ) ;
92
96
const [ excludeOption , setExcludeOption ] = useState < ExcludeOption > ( "Exclude" ) ;
97
+ const [ contestTypeOption , setContestTypeOption ] = useState ( {
98
+ ABC : true ,
99
+ ARC : true ,
100
+ AGC : true ,
101
+ ABC_Like : true ,
102
+ ARC_Like : true ,
103
+ AGC_Like : true ,
104
+ } ) ;
93
105
const [ selectedPreset , setSelectedPreset ] = useState ( ABC_PRESET ) ;
94
106
const problems = useProblems ( ) ?? [ ] ;
95
107
const problemModels = useProblemModelMap ( ) ;
96
108
const submissions =
97
109
useMultipleUserSubmissions ( props . expectedParticipantUserIds ) . data ?? [ ] ;
98
110
const alreadySolvedProblemIds = new Set ( submissions . map ( ( s ) => s . problem_id ) ) ;
99
111
const lastSolvedTimeMap = getLastSolvedTimeMap ( submissions ) ;
112
+ const { data : contests } = useContests ( ) ;
113
+
114
+ const contestTypeKeyToDisplayName = ( key : string ) => {
115
+ if ( key . includes ( "Like" ) ) {
116
+ return key . replace ( "_" , "-" ) ;
117
+ } else {
118
+ return key ;
119
+ }
120
+ } ;
100
121
101
122
return (
102
123
< Form className = { "w-100" } >
@@ -142,6 +163,31 @@ export const ProblemSetGenerator: React.FC<Props> = (props) => {
142
163
</ InputGroup >
143
164
</ Col >
144
165
</ FormGroup >
166
+ < FormGroup row >
167
+ < Col sm = { 6 } >
168
+ < Label > Include / Exclude Contest Types</ Label >
169
+ < InputGroup >
170
+ < ButtonGroup >
171
+ { Object . keys ( contestTypeOption ) . map ( ( contestType ) => {
172
+ return (
173
+ < Button
174
+ key = { contestType }
175
+ active = { contestTypeOption [ contestType ] as boolean }
176
+ onClick = { ( ) : void => {
177
+ setContestTypeOption ( {
178
+ ...contestTypeOption ,
179
+ [ contestType ] : ! contestTypeOption [ contestType ] ,
180
+ } ) ;
181
+ } }
182
+ >
183
+ { contestTypeKeyToDisplayName ( contestType ) }
184
+ </ Button >
185
+ ) ;
186
+ } ) }
187
+ </ ButtonGroup >
188
+ </ InputGroup >
189
+ </ Col >
190
+ </ FormGroup >
145
191
< FormGroup row >
146
192
< Col sm = { 6 } >
147
193
< Label > Difficulty Adjustment Preset</ Label >
@@ -278,6 +324,26 @@ export const ProblemSetGenerator: React.FC<Props> = (props) => {
278
324
} ) ;
279
325
}
280
326
327
+ let candidateContests : Contest [ ] = [ ] ;
328
+ Object . keys ( contestTypeOption ) . forEach ( ( contestType ) => {
329
+ if ( contestTypeOption [ contestType ] ) {
330
+ const filteredContests = contests . filter ( ( contest ) => {
331
+ return (
332
+ contestTypeKeyToDisplayName ( contestType ) ===
333
+ classifyContest ( contest )
334
+ ) ;
335
+ } ) ;
336
+ candidateContests = candidateContests . concat (
337
+ filteredContests
338
+ ) ;
339
+ }
340
+ } ) ;
341
+ candidateProblems = candidateProblems . filter ( ( p ) => {
342
+ return candidateContests
343
+ . map ( ( contest ) => contest . id )
344
+ . includes ( p . problem . contest_id ) ;
345
+ } ) ;
346
+
281
347
candidateProblems = candidateProblems . filter ( ( p ) => {
282
348
if ( excludeOption === "Exclude submitted" ) {
283
349
return ! alreadySolvedProblemIds . has ( p . problem . id ) ;
0 commit comments