@xcpcio/core 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -377,6 +377,15 @@ function getImageSource(image) {
377
377
  return "";
378
378
  }
379
379
 
380
+ class RankStatistics {
381
+ constructor() {
382
+ this.teamSolvedNum = [];
383
+ }
384
+ reset() {
385
+ this.teamSolvedNum = [];
386
+ }
387
+ }
388
+
380
389
  class Team {
381
390
  constructor() {
382
391
  this.id = "";
@@ -642,6 +651,7 @@ class Rank {
642
651
  this.teamsMap = new Map(this.teams.map((t) => [t.id, t]));
643
652
  this.submissions = ___default.cloneDeep(submissions).sort(Submission.compare);
644
653
  this.submissionsMap = new Map(this.submissions.map((s) => [s.id, s]));
654
+ this.rankStatistics = new RankStatistics();
645
655
  }
646
656
  buildRank(options) {
647
657
  (() => {
@@ -728,6 +738,13 @@ class Rank {
728
738
  }
729
739
  }
730
740
  })();
741
+ (() => {
742
+ this.rankStatistics.reset();
743
+ this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
744
+ for (const t of this.teams) {
745
+ this.rankStatistics.teamSolvedNum[t.solvedProblemNum]++;
746
+ }
747
+ })();
731
748
  return this;
732
749
  }
733
750
  }
@@ -827,6 +844,7 @@ exports.ContestIndexConfig = ContestIndexConfig;
827
844
  exports.Problem = Problem;
828
845
  exports.ProblemStatistics = ProblemStatistics;
829
846
  exports.Rank = Rank;
847
+ exports.RankStatistics = RankStatistics;
830
848
  exports.Resolver = Resolver;
831
849
  exports.Submission = Submission;
832
850
  exports.Team = Team;
package/dist/index.d.ts CHANGED
@@ -129,6 +129,12 @@ declare function createContest(contestJSON: Contest$1): Contest;
129
129
 
130
130
  declare function getImageSource(image: Image): string;
131
131
 
132
+ declare class RankStatistics {
133
+ teamSolvedNum: Array<number>;
134
+ constructor();
135
+ reset(): void;
136
+ }
137
+
132
138
  declare class Team {
133
139
  id: string;
134
140
  name: string;
@@ -161,6 +167,7 @@ declare class Rank {
161
167
  teamsMap: Map<string, Team>;
162
168
  submissions: Submissions;
163
169
  submissionsMap: Map<string, Submission>;
170
+ rankStatistics: RankStatistics;
164
171
  constructor(contest: Contest, teams: Teams, submissions: Submissions);
165
172
  buildRank(options?: {
166
173
  timestamp?: number;
@@ -191,4 +198,4 @@ declare function isRejected(status: SubmissionStatus): boolean;
191
198
  declare function isPending(status: SubmissionStatus): boolean;
192
199
  declare function isNotCalculatedPenaltyStatus(status: SubmissionStatus): boolean;
193
200
 
194
- export { Contest, ContestIndex, ContestIndexConfig, ContestIndexList, Problem, ProblemStatistics, Problems, Rank, Resolver, Submission, Submissions, Team, TeamProblemStatistics, Teams, calcDict, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, stringToSubmissionStatus };
201
+ export { Contest, ContestIndex, ContestIndexConfig, ContestIndexList, Problem, ProblemStatistics, Problems, Rank, RankStatistics, Resolver, Submission, Submissions, Team, TeamProblemStatistics, Teams, calcDict, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, stringToSubmissionStatus };
package/dist/index.mjs CHANGED
@@ -361,6 +361,15 @@ function getImageSource(image) {
361
361
  return "";
362
362
  }
363
363
 
364
+ class RankStatistics {
365
+ constructor() {
366
+ this.teamSolvedNum = [];
367
+ }
368
+ reset() {
369
+ this.teamSolvedNum = [];
370
+ }
371
+ }
372
+
364
373
  class Team {
365
374
  constructor() {
366
375
  this.id = "";
@@ -626,6 +635,7 @@ class Rank {
626
635
  this.teamsMap = new Map(this.teams.map((t) => [t.id, t]));
627
636
  this.submissions = _.cloneDeep(submissions).sort(Submission.compare);
628
637
  this.submissionsMap = new Map(this.submissions.map((s) => [s.id, s]));
638
+ this.rankStatistics = new RankStatistics();
629
639
  }
630
640
  buildRank(options) {
631
641
  (() => {
@@ -712,6 +722,13 @@ class Rank {
712
722
  }
713
723
  }
714
724
  })();
725
+ (() => {
726
+ this.rankStatistics.reset();
727
+ this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
728
+ for (const t of this.teams) {
729
+ this.rankStatistics.teamSolvedNum[t.solvedProblemNum]++;
730
+ }
731
+ })();
715
732
  return this;
716
733
  }
717
734
  }
@@ -804,4 +821,4 @@ class Resolver extends Rank {
804
821
  }
805
822
  }
806
823
 
807
- export { Contest, ContestIndex, ContestIndexConfig, Problem, ProblemStatistics, Rank, Resolver, Submission, Team, TeamProblemStatistics, calcDict, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, stringToSubmissionStatus };
824
+ export { Contest, ContestIndex, ContestIndexConfig, Problem, ProblemStatistics, Rank, RankStatistics, Resolver, Submission, Team, TeamProblemStatistics, calcDict, createContest, createContestIndex, createContestIndexList, createDayJS, createProblem, createProblems, createProblemsByProblemIds, createSubmission, createSubmissions, createTeam, createTeams, getImageSource, getTimeDiff, getTimestamp, isAccepted, isNotCalculatedPenaltyStatus, isPending, isRejected, stringToSubmissionStatus };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcpcio/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "XCPCIO Core",
5
5
  "author": "Dup4 <lyuzhi.pan@gmail.com>",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "dayjs": "^1.11.8",
44
44
  "lodash": "^4.17.21",
45
- "@xcpcio/types": "0.4.0"
45
+ "@xcpcio/types": "0.4.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@babel/types": "^7.22.4",
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./utils";
3
3
  export * from "./contest";
4
4
  export * from "./image";
5
5
  export * from "./problem";
6
+ export * from "./rank-statistics";
6
7
  export * from "./rank";
7
8
  export * from "./resolver";
8
9
  export * from "./submission-status";
@@ -0,0 +1,11 @@
1
+ export class RankStatistics {
2
+ teamSolvedNum: Array<number>;
3
+
4
+ constructor() {
5
+ this.teamSolvedNum = [];
6
+ }
7
+
8
+ reset() {
9
+ this.teamSolvedNum = [];
10
+ }
11
+ }
package/src/rank.ts CHANGED
@@ -6,6 +6,7 @@ import { Team } from "./team";
6
6
  import type { Submissions } from "./submission";
7
7
  import { Submission } from "./submission";
8
8
  import { TeamProblemStatistics } from "./problem";
9
+ import { RankStatistics } from "./rank-statistics";
9
10
 
10
11
  export class Rank {
11
12
  readonly contest: Contest;
@@ -16,6 +17,8 @@ export class Rank {
16
17
  submissions: Submissions;
17
18
  submissionsMap: Map<string, Submission>;
18
19
 
20
+ rankStatistics: RankStatistics;
21
+
19
22
  constructor(contest: Contest, teams: Teams, submissions: Submissions) {
20
23
  this.contest = contest;
21
24
 
@@ -24,6 +27,8 @@ export class Rank {
24
27
 
25
28
  this.submissions = _.cloneDeep(submissions).sort(Submission.compare);
26
29
  this.submissionsMap = new Map(this.submissions.map(s => [s.id, s]));
30
+
31
+ this.rankStatistics = new RankStatistics();
27
32
  }
28
33
 
29
34
  buildRank(options?: { timestamp?: number }) {
@@ -137,6 +142,16 @@ export class Rank {
137
142
  }
138
143
  })();
139
144
 
145
+ (() => {
146
+ this.rankStatistics.reset();
147
+
148
+ this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
149
+
150
+ for (const t of this.teams) {
151
+ this.rankStatistics.teamSolvedNum[t.solvedProblemNum]++;
152
+ }
153
+ })();
154
+
140
155
  return this;
141
156
  }
142
157
  }