Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

immortalfox's blog

By immortalfox, 5 years ago, In English

Hey I took a code made by (Adhami) and I modified it a bit so it gets every Div. 2 and tracks if you solved the C (C,C1,C2) problems in it! good luck have fun y'all.(Adhami's code)

import urllib.request, json
import datetime
s = []
w = []
with urllib.request.urlopen("https://codeforces.com/api/contest.list") as url:
	data = json.loads(url.read().decode())
	for x in data["result"]:
		if x["name"].endswith("(Div. 2)"):
			w.append(x["name"])
			s.append(x["id"])
e = [""]*len(w)

#Edit this line to your handle:
USER_NAME = "Corvus"

with urllib.request.urlopen("https://codeforces.com/api/user.status?handle="+USER_NAME) as url:
	data = json.loads(url.read().decode())
	for x in data["result"]:
		if "verdict" in x and "contestId" in x:
			if x['verdict'] == 'OK':
				for i in range(0,len(s)):
					if x["contestId"] == s[i]:
						e[i] += x["problem"]["index"]
						break
push = ""
def contest(solved):
  if solved == "":
    return solved
  ans = ""
  done = [""]*30
  counter = 0
  for x in range(0,len(solved) - 1):
    if solved[x] + solved[x + 1] == "C1" or solved[x] + solved[x + 1] == "C2":
      push = solved[x] + solved[x++ + 1]
    elif solved[x] == "C":
      push = solved[x]
    else:
     push = ""
    if push in done:
      push = ""
    done[counter] = push
    counter = counter + 1    
    ans += "You solved " + push + "! " if push != "" else ""
  return ans

for i in range(0,len(w)):
  print("#" + str(i+1) + " https://codeforces.com/contest/" + str(s[len(w)-i-1]) + " : " + contest("".join(e[len(w)-i-1])))

Change [USER_NAME] to match yours, and it will print it in this format :

# 1 https://codeforces.com/contest/14 : You solved C!
# 2 https://codeforces.com/contest/34 :
# 3 https://codeforces.com/contest/35 :
# 4 https://codeforces.com/contest/41 :
....
# 426 https://codeforces.com/contest/1204 : You solved C!
# 427 https://codeforces.com/contest/1215 :
# 428 https://codeforces.com/contest/1230 : You solved C!
# 429 https://codeforces.com/contest/1228 :

(should work perfectly fine)

you can just go here to run it(the code is there as well).

Full text and comments »

  • Vote: I like it
  • +7
  • Vote: I do not like it