· 6 years ago · Oct 22, 2019, 03:40 AM
1package main
2
3import (
4 "context"
5 "fmt"
6 "github.com/togatoga/goforces"
7 "log"
8 "os"
9)
10
11func main() {
12 ctx := context.Background()
13 //logger
14 logger := log.New(os.Stderr, "*** ", log.LstdFlags)
15 //Codeforces client
16 api, _ := goforces.NewClient(logger)
17 //Problems
18 //problems, _ := api.GetProblemSetProblems(ctx, &goforces.ProblemSetProblemsOptions{Tags: []string{"dp"}})
19 //fmt.Printf("%+v\n", problems)
20
21 //Contest list
22 //contestList, _ := api.GetContestList(ctx, nil)
23
24 //If you use authorized methods, you must set your key and secret
25 api.SetAPIKey("f3d968eea83ad8d5f21cad0365edcc200439c6f0")
26 api.SetAPISecret("b30c206b689d5ba004534c6780aa7be8e234a7f3")
27 //User friends
28
29 //ContestStatndingsOptions represents the option of /contest.standings
30 //type ContestStatndingsOptions struct {
31 // From int
32 // Count int
33 // Handles []string
34 // Room int
35 // ShowUnofficial bool
36 //}
37
38 opt := goforces.ContestStatndingsOptions{
39 From: 1,
40 Count: 2,
41 //Handles: []string{"Veras"},
42 ShowUnofficial: true,
43 }
44 standings, _ := api.GetContestStandings(ctx,250026,&opt)
45 fmt.Printf("%+v\n", standings)
46
47
48 //
49 //listopt := goforces.ContestListOptions{Gym:true}
50 //
51 //x, _ := api.GetContestList(ctx, &listopt)
52 //
53 //sort.Slice(x, func(i, j int) bool {
54 // return false
55 //})
56 //
57 //
58 //sort.Slice(standings, func(i, j int) bool {
59 // return false
60 //})
61
62 //friends, _ := api.GetUserFriends(ctx, nil)
63 //fmt.Printf("%+v\n", friends)
64}