@@ -16,11 +16,13 @@ import {
16
16
} from "reactstrap" ;
17
17
import React , { useState } from "react" ;
18
18
import {
19
+ useContests ,
19
20
useMultipleUserSubmissions ,
20
21
useProblemModelMap ,
21
22
useProblems ,
22
23
} from "../api/APIClient" ;
23
24
import Problem from "../interfaces/Problem" ;
25
+ import Contest from "../interfaces/Contest" ;
24
26
import { shuffleArray } from "../utils" ;
25
27
import {
26
28
ExcludeOption ,
@@ -30,6 +32,7 @@ import {
30
32
getLastSolvedTimeMap ,
31
33
getMaximumExcludeElapsedSecond ,
32
34
} from "../utils/LastSolvedTime" ;
35
+ import { classifyContest } from "../utils/ContestClassifier" ;
33
36
import { isProblemModelWithDifficultyModel } from "../interfaces/ProblemModel" ;
34
37
35
38
interface Props {
@@ -107,6 +110,7 @@ export const ProblemSetGenerator: React.FC<Props> = (props) => {
107
110
useMultipleUserSubmissions ( props . expectedParticipantUserIds ) . data ?? [ ] ;
108
111
const alreadySolvedProblemIds = new Set ( submissions . map ( ( s ) => s . problem_id ) ) ;
109
112
const lastSolvedTimeMap = getLastSolvedTimeMap ( submissions ) ;
113
+ const { data : contests } = useContests ( ) ;
110
114
111
115
const contestTypeKeyToDisplayName = ( key : string ) => {
112
116
if ( key . includes ( "Like" ) ) {
@@ -323,6 +327,26 @@ export const ProblemSetGenerator: React.FC<Props> = (props) => {
323
327
} ) ;
324
328
}
325
329
330
+ let candidateContests : Contest [ ] = [ ] ;
331
+ Object . keys ( contestTypeOption ) . forEach ( ( contestType ) => {
332
+ if ( contestTypeOption [ contestType ] ) {
333
+ const filteredContests = contests . filter ( ( contest ) => {
334
+ return (
335
+ contestTypeKeyToDisplayName ( contestType ) ===
336
+ classifyContest ( contest )
337
+ ) ;
338
+ } ) ;
339
+ candidateContests = candidateContests . concat (
340
+ filteredContests
341
+ ) ;
342
+ }
343
+ } ) ;
344
+ candidateProblems = candidateProblems . filter ( ( p ) => {
345
+ return candidateContests
346
+ . map ( ( contest ) => contest . id )
347
+ . includes ( p . problem . contest_id ) ;
348
+ } ) ;
349
+
326
350
candidateProblems = candidateProblems . filter ( ( p ) => {
327
351
if ( excludeOption === "Exclude submitted" ) {
328
352
return ! alreadySolvedProblemIds . has ( p . problem . id ) ;
0 commit comments