Beispiel #1
0
        public static async Task RunMyChild()
        {
            var request     = new UserStatusRequest();
            var submissions = await request.GetUserSubmissionsAsync("Laggy", from : 1, count : 10);

            var anotherRequest = new UserInfoRequest();
            var user           = anotherRequest.GetUserInfo("Laggy");
            var users          = await anotherRequest.GetUsersInfoAsync(new [] { "Laggy", "majk", "tourist" });

            var yetAnotherRequest = new ContestRatingChangesRequest();
            var changes           = await yetAnotherRequest.GetRatingChangesAsync(contestId : 1000);

            foreach (var change in changes)
            {
                Console.WriteLine($"{change.Handle} has got {change.NewRating - change.OldRating}");
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            List <ICPCTeam> icpcTeams = new List <ICPCTeam>();

            using (SqlConnection con = new SqlConnection("Data Source = 192.168.134.133, 1433; Network Library=DBMSSOCN; Initial Catalog = DB; User ID = sa; Password = pw"))
            {
                con.Open();
                SqlCommand cmd    = new SqlCommand("SELECT * FROM _ICPCEntries", con);
                var        reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    icpcTeams.Add(new ICPCTeam()
                    {
                        Country    = reader["Country"] as string,
                        University = reader["University"] as string,
                        Member1    = reader["Member1"] as string,
                        Member2    = reader["Member2"] as string,
                        Member3    = reader["Member3"] as string,
                        TeamRating = 0
                    });
                }
            }
            foreach (var team in icpcTeams)
            {
                List <string> members = new List <string>();
                if (!string.IsNullOrEmpty(team.Member1))
                {
                    members.Add(team.Member1);
                }
                if (!string.IsNullOrEmpty(team.Member2))
                {
                    members.Add(team.Member2);
                }
                if (!string.IsNullOrEmpty(team.Member3))
                {
                    members.Add(team.Member3);
                }

                List <double> ratings = new List <double>();
                foreach (var member in members)
                {
                    var req  = new UserInfoRequest();
                    var user = req.GetUserInfo(member);
                    ratings.Add(user.Rating);

                    Thread.Sleep(150);
                }

                var teamRating = cfapi.Helpers.CodeforcesHelper.AggregateRatings(ratings);
                team.TeamRating = teamRating;
            }

            icpcTeams = icpcTeams.OrderByDescending(i => i.TeamRating).ToList();
            int rank = 1;

            Console.WriteLine("<table><thead><tr><th>Rank</th> <th>Country</th> <th>University</th> <th>Member1</th> <th>Member2</th> <th>Member3</th> <th>Team Rating</th></tr> </thead>");
            foreach (var team in icpcTeams)
            {
                if (team.TeamRating == 1.0)
                {
                    Console.WriteLine($"<tr> <td>{rank++}</td> <td>{team.Country}</td> <td>{team.University}</td> <td>{team.Member1}</td> <td>{team.Member2}</td> <td>{team.Member3}</td> <td>{team.TeamRating}</td> </tr>");
                }
                else
                {
                    Console.WriteLine($"<tr> <td>{rank++}</td> <td>{team.Country}</td> <td>{team.University}</td> <td>[user:{team.Member1}]</td> <td>[user:{team.Member2}]</td> <td>[user:{team.Member3}]</td> <td>{team.TeamRating.ToString("0.###")}</td> </tr>");
                }
            }
            Console.WriteLine("</table>");
            Console.Read();
        }
Beispiel #3
0
        static void Main_Old(string[] args)
        {
            Dictionary <IOIEntry, int>  scoreboard       = new Dictionary <IOIEntry, int>();
            Dictionary <string, string> nameHandleLookup = new Dictionary <string, string>();
            Dictionary <string, string> nameCodeLookup   = new Dictionary <string, string>();
            Dictionary <string, string> codeHandleLookup = new Dictionary <string, string>();

            var wc = new HttpClient();

            var scoresRaw  = File.ReadAllText("scores.txt");
            var scoresJson = JsonConvert.DeserializeObject <dynamic>(scoresRaw);


            var usersRaw  = File.ReadAllText("users.txt");
            var usersJson = JsonConvert.DeserializeObject <dynamic>(usersRaw);

            foreach (var entry in usersJson)
            {
                foreach (var data in entry)
                {
                    nameCodeLookup.Add(data["f_name"].ToString() + " " + data["l_name"].ToString(), entry.Name.ToString());
                    //Console.WriteLine(entry.Name + " " + data["f_name"] + " " + data["l_name"]);
                }
            }

            var    ioiHandles = new StreamReader("handles.txt");
            string line;

            while ((line = ioiHandles.ReadLine()) != null)
            {
                string name = "";
                var    data = line.Split('\t');
                for (int i = 0; i < data.Length - 1; i++)
                {
                    name += data[i] + " ";
                }

                name = name.TrimEnd();
                if (data.Length < 3)
                {
                    continue;
                }
                nameHandleLookup.Add(name, data.Last());
                scoreboard.Add(new IOIEntry()
                {
                    Name = name, CountryCode = nameCodeLookup.FirstOrDefault(i => i.Key == name).Value
                }, 0);
            }

            foreach (var entry in nameHandleLookup)
            {
                var key = nameCodeLookup.FirstOrDefault(i => i.Key.ToLower() == entry.Key.ToLower()).Value;
                var val = nameHandleLookup.FirstOrDefault(i => i.Key.ToLower() == entry.Key.ToLower()).Value;
                codeHandleLookup.Add(key, val);
            }

            foreach (var entry in scoresJson)
            {
                foreach (var data in entry)
                {
                    //Console.WriteLine(entry.Name);
                    foreach (var prb in data)
                    {
                        var usr = scoreboard.FirstOrDefault(i => i.Key.CountryCode == entry.Name.ToString());
                        if (usr.Key == null)
                        {
                            continue;
                        }
                        switch (prb.Name.ToString())
                        {
                        case "rect":
                            usr.Key.P1 = prb.Value;
                            break;

                        case "shoes":
                            usr.Key.P2 = prb.Value;
                            break;

                        case "split":
                            usr.Key.P3 = prb.Value;
                            break;

                        case "line":
                            usr.Key.P4 = prb.Value;
                            break;

                        case "vision":
                            usr.Key.P5 = prb.Value;
                            break;

                        case "walk":
                            usr.Key.P6 = prb.Value;
                            break;
                        }
                    }
                }
            }

            foreach (var entry in scoreboard)
            {
                entry.Key.Day1Total = entry.Key.P1 + entry.Key.P2 + entry.Key.P3;
                entry.Key.Day2Total = entry.Key.P4 + entry.Key.P5 + entry.Key.P6;
                entry.Key.Total     = entry.Key.Day1Total + entry.Key.Day2Total;
            }

            foreach (var entry in scoreboard)
            {
                var handle = codeHandleLookup.FirstOrDefault(i => i.Key == entry.Key.CountryCode).Value;
                if (!String.IsNullOrEmpty(handle))
                {
                    var req = new UserInfoRequest();
                    var usr = req.GetUserInfo(handle);

                    if (usr.Rating != 0)
                    {
                        Console.WriteLine($"{usr.Rating}\t{entry.Key.Total}");
                    }
                    Thread.Sleep(250);
                }
            }
            //foreach(var entry in nameHandleLookup)
            //{
            //    var usr = nameCodeLookup.Count(i => i.Key.ToLower() == entry.Key.ToLower());

            //    if (usr == 0)
            //    {
            //        Console.WriteLine(entry.Key);
            //    }
            //}
            Console.Read();
        }