-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtCoder.py
64 lines (55 loc) · 1.72 KB
/
AtCoder.py
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
# sample input:
# RuinerWorm null_nerd
# 80 120
'''
mikaeel RuinerWorm null_nerd reza
abc080_a abc090_a abc095_a abc090_a abc096_a
100
'''
import urllib.parse
import urllib.request
from os import system, name
users = input().split()
problem_ids = input().split()
total_score = int(input())
problem_score = total_score / len(problem_ids)
output = {}
total_pages = len(problem_ids) * len(users)
page_id = 0
def clear_screen():
# for windows
if name == 'nt':
_ = system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = system('clear')
for user in users:
output[user] = {"problemResult": []}
sum_score = 0
for problem_id in problem_ids:
clear_screen()
page_id += 1
print(str(page_id * 100 / total_pages) + "%")
contest_id = problem_id.split('_')[0]
url = 'https://atcoder.jp/contests/' + contest_id + '/submissions?f.Task=' + problem_id + '&f.Language=&f.Status=AC&f.User=' + user
response = urllib.request.urlopen(url)
webContent = response.read()
result = webContent.decode("utf-8").find('class="text-right submission-score"')
if result != -1:
sum_score += problem_score
output[user]["problemResult"].append(problem_score)
else:
output[user]["problemResult"].append(0)
output[user]["total_points"] = sum_score
output = {k: v for k, v in sorted(output.items(), key=lambda item: (-item[1]['total_points']))}
last_user = None
last_ans = 1
ans = 1
for user in output:
if last_user is None or output[last_user]['total_points'] > output[user]['total_points']:
last_ans = ans
last_user = user
output[user]['rank'] = last_ans
ans += 1
clear_screen()
print(output)