public static T Init <T>(Codeforces api) where T : MethodsGroup, new() { return(new T { Api = api }); }
public static void BlogEntryView1(Codeforces api) { var view = api.BlogEntry.View(44362).Result; Console.WriteLine(view.Title); Console.WriteLine("Rating: " + view.Rating); Console.WriteLine("Author: " + view.AuthorHandle); }
public static void BlogEntryComments1(Codeforces api) { var view = api.BlogEntry.Comments(44362).Result; Console.WriteLine("Comments: " + view.Length); foreach (var x in view) { Console.WriteLine("{0}: {1}", x.CommentatorHandle, x.Text); } }
static void Main(string[] args) { var api = new Codeforces(); var calc = new CodeforcesRatingCalculator2(); Console.Write("Enter contest id: "); var contestId = int.Parse(Console.ReadLine().Trim()); var standings = api.Contest.Standings(contestId, showUnofficial: false).Result; var registrants = api.Contest.Registrants(contestId).Result; Console.WriteLine("Standings rows: " + standings.Rows.Length); Console.WriteLine("Registrants rows: " + registrants.Length); var magicRating = new Dictionary <string, int>(); foreach (var registrant in registrants) { foreach (var member in registrant.Party.Members) { magicRating[member.Handle] = registrant.Rating; } } var previousRating = new Dictionary <Party, int>(); foreach (var row in standings.Rows) { int rating; magicRating.TryGetValue(row.Party.Members.First().Handle, out rating); if (rating == 0) { rating = 1500; } previousRating[row.Party] = rating; } var sw = Stopwatch.StartNew(); var calculated = calc.CalculateRatingChanges(previousRating, standings.Rows, null); sw.Stop(); Console.WriteLine("Calculated after {0} ms", sw.ElapsedMilliseconds); using (var file = File.CreateText("result.txt")) { foreach (var changeRow in calculated.OrderBy(x => - x.Value)) { var name = string.Format("{0} ({1})", changeRow.Key.TeamName, string.Join(", ", changeRow.Key.Members.Select(x => x.Handle))); file.WriteLine("{0} : {1}", name, changeRow.Value); } } Console.WriteLine("Saved to result.txt"); }
public static void UpdateContests() { var cf = new Codeforces(DateTime.Now); var dmoj = new DMOJ(DateTime.Now); Contests?.Clear(); Contests = cf.GetContestsList().Result; Contests.AddRange(dmoj.GetContestsList().Result); Contests?.Sort(); }
public static void RecentActionsTest1(Codeforces api) { foreach (var x in api.RecentActions(10).Result) { if (x.Comment != null) { Console.WriteLine("[comment][{0}] {1}: {2}", x.Time, x.Comment.CommentatorHandle, x.Comment.Text); } if (x.BlogEntry != null) { Console.WriteLine("[blog][{0}] {1}", x.Time, x.BlogEntry.Title); } } }
static void Main(string[] args) { var api = new Codeforces(); var sw = new Stopwatch(); foreach (var test in Tests) { Console.WriteLine(test.Key + ":"); sw.Restart(); test.Value(api); sw.Stop(); Console.WriteLine("{0} complete after {1} ms", test.Key, sw.ElapsedMilliseconds); Console.WriteLine("Press any key to continue"); Console.ReadKey(true); } }
private void ReadData() { var cf = new Codeforces(); AllYearPartition = new List <Partition>(); var cups = new[] { (15, 562), (16, 695), (17, 823), (18, 951) };