10
10
CODEFORCES_URL = "https://codeforces.com"
11
11
12
12
13
- def get_info (contest_id , index , lang = 'en' ):
13
+ def get_info (contest_id , index , gym = False , lang = 'en' ):
14
14
"""
15
15
Get info for a contest problem.
16
16
@@ -23,6 +23,9 @@ def get_info(contest_id, index, lang='en'):
23
23
Usually a letter of a letter, followed by a digit, that
24
24
represent a problem index in a contest. It can be seen in
25
25
problem URL. For example: /contest/566/**A**
26
+ gym: bool
27
+ If true gym problem is returned otherwise regular problem is
28
+ returned.
26
29
27
30
Returns
28
31
-------
@@ -36,10 +39,16 @@ def get_info(contest_id, index, lang='en'):
36
39
Sample tests given for the problem.
37
40
38
41
"""
39
- problem_url = os .path .join (
40
- CODEFORCES_URL ,
41
- "contest/%d/problem/%s?lang=%s" % (contest_id , index , lang )
42
- )
42
+ if gym :
43
+ problem_url = os .path .join (
44
+ CODEFORCES_URL ,
45
+ "gym/%d/problem/%s?lang=%s" % (contest_id , index , lang )
46
+ )
47
+ else :
48
+ problem_url = os .path .join (
49
+ CODEFORCES_URL ,
50
+ "contest/%d/problem/%s?lang=%s" % (contest_id , index , lang )
51
+ )
43
52
44
53
with urllib .request .urlopen (problem_url ) as res :
45
54
soup = BeautifulSoup (res .read (), 'html.parser' )
@@ -49,8 +58,13 @@ def get_info(contest_id, index, lang='en'):
49
58
time_limit = soup .find_all ("div" , class_ = "time-limit" )[0 ].text [19 :]
50
59
memory_limit = soup .find_all ("div" , class_ = "memory-limit" )[0 ].text [21 :]
51
60
52
- inputs = [i .pre .text .lstrip ('\n ' ) for i in soup .find_all ("div" , class_ = "input" )]
53
- outputs = [i .pre .text .lstrip ('\n ' ) for i in soup .find_all ("div" , class_ = "output" )]
61
+ inputs = [
62
+ i .pre .text .lstrip ('\n ' ) for i in soup .find_all ("div" , class_ = "input" )
63
+ ]
64
+
65
+ outputs = [
66
+ i .pre .text .lstrip ('\n ' ) for i in soup .find_all ("div" , class_ = "output" )
67
+ ]
54
68
55
69
sample_tests = zip (inputs , outputs )
56
70
0 commit comments