Esempio n. 1
0
        public static async Task BruteforceProblems()
        {
            var contestReq = new ContestListRequest();

            var contests = await contestReq.GetContestListAsync(includeGym : false);

            foreach (var contest in contests.Where(i => i.Phase == ContestPhase.FINISHED))
            {
                var req            = new ContestStandingsRequest();
                var contestDetails = await req.GetContestStandingsAsync(contestId : contest.Id, from : 1, count : 1);

                var contestProblems = contestDetails?.Problems;

                if (contestProblems == null)
                {
                    continue;
                }

                foreach (var problem in contestProblems)
                {
                    if (problem.Index == "C" && problem.Tags.Contains("fft"))
                    {
                        Console.WriteLine($"Found at ContestId: {problem.ContestId}");
                    }
                }
            }
            Console.WriteLine("Done!");
        }
Esempio n. 2
0
        public static async Task BuildGym()
        {
            var req     = new ContestListRequest();
            var gymList = await req.GetContestListAsync(true);

            Dictionary <int, List <Problem> > dic = new Dictionary <int, List <Problem> >();

            foreach (var contest in gymList)
            {
                var req2      = new ContestStandingsRequest();
                var standings = await req2.GetContestStandingsAsync(contest.Id, 1, 1);

                dic.Add(contest.Id, new List <Problem>());
                foreach (var problem in standings.Problems)
                {
                    dic[contest.Id].Add(problem);
                }
            }

            Console.WriteLine("Done");
            var properDic  = dic.ToDictionary(k => k.Key.ToString(), v => v.Value);
            var serializer = new JavaScriptSerializer().Serialize(properDic);

            File.WriteAllText("contests.json", serializer);
        }
Esempio n. 3
0
        public static async void GetLegends()
        {
            var req      = new ContestListRequest();
            var contests = await req.GetContestListAsync();

            contests = contests.Where(i => i.Phase == ContestPhase.FINISHED).ToList();

            foreach (var contest in contests)
            {
                try
                {
                    var req2      = new ContestStandingsRequest();
                    var standings = await req2.GetContestStandingsAsync(contest.Id, 1, 1, null, 0, false);

                    var users = standings.Rows.FindAll(i => i.Rank == 1);
                    foreach (var user in users)
                    {
                        if (count.ContainsKey(user.Party.Members[0].Handle))
                        {
                            count[user.Party.Members[0].Handle]++;
                        }
                        else
                        {
                            count.Add(user.Party.Members[0].Handle, 1);
                        }
                    }
                    await Task.Delay(205);
                }
                catch { }
            }
            count = count.OrderByDescending(i => i.Value).ToDictionary(x => x.Key, x => x.Value);

            int ok = 0;

            foreach (var x in count)
            {
                Console.WriteLine($"{ok + 1}) {x.Key} has {x.Value} wins.");
                ok++;
                if (ok == 25)
                {
                    break;
                }
            }
        }
    public async Task ContestList(int count = 0)
    {
        var contestRequest = new ContestListRequest();
        var contests       = await contestRequest.GetContestListAsync(includeGym : false);

        contests.Reverse();
        if (count <= 0)
        {
            count = contests.Count();
        }

        var embed = new EmbedBuilder
        {
            Description = "***>> List of upcoming contests:***",
            Color       = Color.Red
        };

        foreach (var contest in contests.Where(i => i.Phase == ContestPhase.BEFORE))
        {
            if (count == 0)
            {
                break;
            }

            var Name        = contest.Name;
            var Url         = "https://codeforces.com/contests/" + contest.Id.ToString();
            var Type        = contest.Type;
            var StartTime   = DateTimeOffset.FromUnixTimeSeconds(contest.StartTime).AddHours(7);
            var DurationMin = (int)TimeSpan.FromSeconds(contest.Duration).TotalMinutes;
            var Author      = contest.Author;

            string StartDate = $"*{DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(StartTime.Month)}/{StartTime.Day}/{StartTime.Year}* at {StartTime.Hour}:{((StartTime.Minute < 10) ? $"0{StartTime.Minute}" : $"{StartTime.Minute}")} UTC+7";
            string Duration  = $"{(int)(DurationMin / 60)}h " + ((DurationMin % 60 < 10) ? $"0{DurationMin % 60}m" : $"{DurationMin % 60}m");

            embed.AddField($"{StartDate}",
                           $"[{Name}]({Url})\nLength: {Duration}\nAuthor: {Author}");
            --count;
        }