Example #1
0
        private IEnumerable <TeamModel> GetSingleScore()
        {
            var prob = new ScoreCellModel[Problems.Length];

            foreach (var pp in QueryInfo.ScoreCache ?? Enumerable.Empty <ScoreCache>())
            {
                var p = Problems.FirstOrDefault(a => a.ProblemId == pp.ProblemId);
                if (p == null)
                {
                    continue;
                }
                var pid = p.Rank - 1;

                prob[pid] = new ScoreCellModel
                {
                    PendingCount   = pp.PendingRestricted,
                    IsFirstToSolve = pp.FirstToSolve,
                    JudgedCount    = pp.SubmissionRestricted,
                    Score          = pp.ScoreRestricted,
                    SolveTime      = pp.SolveTimeRestricted,
                };
            }

            yield return(new TeamModel
            {
                TeamId = QueryInfo.TeamId,
                TeamName = QueryInfo.TeamName,
                Affiliation = Affiliation.FormalName,
                AffiliationId = Affiliation.ExternalId,
                Category = Category.Name,
                CategoryColor = Category.Color,
                Points = QueryInfo.RankCache.PointsRestricted,
                Penalty = QueryInfo.RankCache.TotalTimeRestricted,
                ShowRank = true,
                Problems = prob,
            });
        }
Example #2
0
        private IEnumerable <TeamModel> GetViewModel(
            bool ispublic,
            IEnumerable <Team> src,
            ProblemStatisticsModel[] stat)
        {
            int rank         = 0;
            int last_rank    = 0;
            int last_point   = int.MinValue;
            int last_penalty = int.MinValue;
            var cats         = new Dictionary <int, TeamCategory>();

            src = IRankingStrategy.SC[Contest.RankingStrategy].SortByRule(src, ispublic);

            foreach (var item in src)
            {
                int    catid   = item.CategoryId;
                string catName = null;
                if (!cats.Keys.Contains(catid))
                {
                    cats.Add(catid, cats2[catid]);
                    catName = cats2[catid].Name;
                }

                int point   = ispublic ? item.RankCache.PointsPublic : item.RankCache.PointsRestricted;
                int penalty = ispublic ? item.RankCache.TotalTimePublic : item.RankCache.TotalTimeRestricted;
                rank++;
                if (last_point != point || last_penalty != penalty)
                {
                    last_rank = rank;
                }
                last_point   = point;
                last_penalty = penalty;

                var prob = new ScoreCellModel[Problems.Length];

                foreach (var pp in item.ScoreCache ?? Enumerable.Empty <ScoreCache>())
                {
                    var p = Problems.FirstOrDefault(a => a.ProblemId == pp.ProblemId);
                    if (p == null)
                    {
                        continue;
                    }
                    var pid = p.Rank - 1;

                    if (ispublic)
                    {
                        prob[pid] = new ScoreCellModel
                        {
                            PendingCount   = pp.PendingPublic,
                            IsFirstToSolve = pp.FirstToSolve,
                            JudgedCount    = pp.SubmissionPublic,
                            Score          = pp.ScorePublic,
                            SolveTime      = pp.SolveTimePublic,
                        };
                    }
                    else
                    {
                        prob[pid] = new ScoreCellModel
                        {
                            PendingCount   = pp.PendingRestricted,
                            IsFirstToSolve = pp.FirstToSolve,
                            JudgedCount    = pp.SubmissionRestricted,
                            Score          = pp.ScoreRestricted,
                            SolveTime      = pp.SolveTimeRestricted,
                        };
                    }

                    if (prob[pid].Score.HasValue)
                    {
                        stat[pid].FirstSolve ??= prob[pid].Score;
                        stat[pid].Accepted++;
                        stat[pid].Rejected += prob[pid].JudgedCount - 1;
                        stat[pid].Pending  += prob[pid].PendingCount;
                    }
                    else
                    {
                        stat[pid].Rejected += prob[pid].JudgedCount;
                        stat[pid].Pending  += prob[pid].PendingCount;
                    }
                }

                yield return(new TeamModel
                {
                    ContestId = IsPublic ? default(int?) : item.ContestId,
                    TeamId = item.TeamId,
                    TeamName = item.TeamName,
                    Affiliation = affs2.GetValueOrDefault(item.AffiliationId)?.FormalName ?? "",
                    AffiliationId = affs2.GetValueOrDefault(item.AffiliationId)?.ExternalId ?? "null",
                    Category = catName,
                    CategoryColor = cats[catid].Color,
                    Points = point,
                    Penalty = penalty,
                    Rank = last_rank,
                    ShowRank = last_rank == rank,
                    Problems = prob,
                });
            }
        }