-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhoSolvedThisProblem.py
More file actions
63 lines (48 loc) · 1.39 KB
/
whoSolvedThisProblem.py
File metadata and controls
63 lines (48 loc) · 1.39 KB
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
# -*- coding: utf-8 -*-
# 問題IDを標準入力から入力すると、userListに含まれるユーザのうちその問題を解いたユーザ名が出力される
from collections import defaultdict
import xml.etree.ElementTree as ET
import urllib2
ME="yazaten"
userList=[
"Respect2D","kioa","yokit9","ik11235","utisam","nkkwe","KNKedge","slip0110",
"komi0222","menphim","ja3rno","dispenser","arsenic28","ayihis","fukku",
"bnsgny","CROW","is0220rk","okkyun","tmbsx","yazaten",
"is0248vx","Nanana","satoshi31043","mots555","ixmel","pikanatsu","kerokero","futo","proru","sarada417","is0268ev","IS0283IR","moon_remon","kinono","is0266hx","Rp7rf",
]
def getUser(id):
response = urllib2.urlopen('http://judge.u-aizu.ac.jp/onlinejudge/webservice/user?id='+id)
return response
def makeUserDataDict():
userDataDict=defaultdict(lambda : 0)
#
for id in userList:
html=getUser(id);
#
tree=ET.parse(html)
root=tree.getroot()
#
userDataDict[id]=root
#
return userDataDict
def getUnderMeList(rankList):
retList=[]
isFoundMe=0
for id in rankList:
if isFoundMe==1 :
retList.append(id)
#
if id[0]==ME :
isFoundMe=1
#
return retList
userDataDict=makeUserDataDict()
while True:
problemNum=input()
if problemNum==-1 :break
for name in userList:
userTree=userDataDict[name]
for num in userTree.findall(".//problem//id"):
if(num.text==problemNum):
print name
break