/
contest.go
175 lines (149 loc) · 6.17 KB
/
contest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package codeforces
import (
"strconv"
)
// GetContestHacks returns list of hacks in the specified contests. Full
// information about hacks is available only after some time after the contest
// end. During the contest user can see only own hacks.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.hacks
func (c *Client) GetContestHacks(contestID int) ([]Hack, error) {
params := make(map[string][]string)
params["contestId"] = []string{strconv.FormatInt(int64(contestID), 10)}
var res []Hack
err := c.makeAPICall("contest.hacks", params, &res)
return res, err
}
// GetContestHacks returns list of hacks in the specified contests. Full
// information about hacks is available only after some time after the contest
// end. During the contest user can see only own hacks.
//
// GetContestHacks is a wrapper around DefaultClient.GetContestHacks.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.hacks
func GetContestHacks(contestID int) ([]Hack, error) {
return DefaultClient.GetContestHacks(contestID)
}
// GetContestList returns information about all available contests.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.list
func (c *Client) GetContestList(gym bool) ([]Contest, error) {
params := make(map[string][]string)
params["gym"] = []string{strconv.FormatBool(gym)}
var res []Contest
err := c.makeAPICall("contest.list", params, &res)
return res, err
}
// GetContestList returns information about all available contests.
//
// GetContestList is a wrapper around DefaultClient.GetContestList.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.list
func GetContestList(gym bool) ([]Contest, error) {
return DefaultClient.GetContestList(gym)
}
// GetContestRatingChanges returns rating changes after the contest.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.ratingChanges
func (c *Client) GetContestRatingChanges(contestID int) ([]RatingChange, error) {
params := make(map[string][]string)
params["contestId"] = []string{strconv.FormatInt(int64(contestID), 10)}
var res []RatingChange
err := c.makeAPICall("contest.ratingChanges", params, &res)
return res, err
}
// GetContestRatingChanges returns rating changes after the contest.
//
// GetContestRatingChanges is a wrapper around
// DefaultClient.GetContestRatingChanges.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.ratingChanges
func GetContestRatingChanges(contestID int) ([]RatingChange, error) {
return DefaultClient.GetContestRatingChanges(contestID)
}
// GetContestStandings returns the description of the contest and the requested
// part of the standings.
//
// Set count to 0 for infinite count.
// Set handles to a empty list to not filter by handles.
// Set room to 0 to show all participants.
//
// Returns object with three fields: "contest", "problems" and "rows".
// Field "contest" contains a Contest object.
// Field "problems" contains a list of Problem objects.
// Field "rows" contains a list of RanklistRow objects.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.standings
func (c *Client) GetContestStandings(contestID, from, count int, handles []string, room int, showUnofficial bool) (Contest, []Problem, []RanklistRow, error) {
params := make(map[string][]string)
params["contestId"] = []string{strconv.FormatInt(int64(contestID), 10)}
params["from"] = []string{strconv.FormatInt(int64(from), 10)}
params["showUnofficial"] = []string{strconv.FormatBool(showUnofficial)}
if count != 0 {
params["count"] = []string{strconv.FormatInt(int64(count), 10)}
}
if len(handles) > 0 {
params["handles"] = handles
}
if room != 0 {
params["room"] = []string{strconv.FormatInt(int64(room), 10)}
}
var res struct {
Contest Contest `json:"contest"`
Problems []Problem `json:"problems"`
Rows []RanklistRow `json:"rows"`
}
err := c.makeAPICall("contest.standings", params, &res)
return res.Contest, res.Problems, res.Rows, err
}
// GetContestStandings returns the description of the contest and the requested
// part of the standings.
//
// Set count to 0 for infinite count.
// Set handles to a empty list to not filter by handles.
// Set room to 0 to show all participants.
//
// Returns object with three fields: "contest", "problems" and "rows".
// Field "contest" contains a Contest object.
// Field "problems" contains a list of Problem objects.
// Field "rows" contains a list of RanklistRow objects.
//
// GetContestStandings is a wrapper around DefaultClient.GetContestStandings.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.standings
func GetContestStandings(contestID, from, count int, handles []string, room int, showUnofficial bool) (Contest, []Problem, []RanklistRow, error) {
return DefaultClient.GetContestStandings(contestID, from, count, handles, room, showUnofficial)
}
// GetContestStatus returns submissions for specified contest. Optionally can
// return submissions of specified user.
//
// Set handle to a empty string to get status for all handles.
// Set count to 0 for infinite count.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.status
func (c *Client) GetContestStatus(contestID int, handle string, from, count int) ([]Submission, error) {
params := make(map[string][]string)
params["contestId"] = []string{strconv.FormatInt(int64(contestID), 10)}
params["from"] = []string{strconv.FormatInt(int64(from), 10)}
if count != 0 {
params["count"] = []string{strconv.FormatInt(int64(count), 10)}
}
if handle != "" {
params["handle"] = []string{handle}
}
var res []Submission
err := c.makeAPICall("contest.status", params, &res)
return res, err
}
// GetContestStatus returns submissions for specified contest. Optionally can
// return submissions of specified user.
//
// Set handle to a empty string to get status for all handles.
// Set count to 0 for infinite count.
//
// GetContestStatus is a wrapper around DefaultClient.GetContestStatus.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#contest.status
func GetContestStatus(contestID int, handle string, from, count int) ([]Submission, error) {
return DefaultClient.GetContestStatus(contestID, handle, from, count)
}