s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s900640077 | p00659 | u957028788 | 1502073437 | Python | Python3 | py | Runtime Error | 0 | 0 | 1010 | while True:
player_nun = int(input())
player_nun = 4
if player_nun == 0:
break
#?????????????????????
whole_data = []
for i in (0, player_nun):
dat = input().split()
p_data = []
p_data.append(dat[0])
for x in dat[1:]:
p_data.append(int(x))
whole_data.append(p_data)
#????????????????????????... |
s268000803 | p00659 | u957028788 | 1502073734 | Python | Python3 | py | Runtime Error | 0 | 0 | 1031 | while True:
player_nun = int(input())
player_nun = 4
if player_nun == 0:
break
#?????????????????????
whole_data = []
for i in range(0, player_nun):
dat = input().split()
p_data = []
p_data.append(dat[0])
for x in dat[1:]:
p_data.append(int(x))
whole_data.append(p_data)
print(whole_data)
#???... |
s059284963 | p00659 | u957028788 | 1502073781 | Python | Python3 | py | Runtime Error | 0 | 0 | 1031 | while True:
player_nun = int(input())
player_nun = 4
if player_nun == 0:
break
#?????????????????????
whole_data = []
for i in range(0, player_nun):
dat = input().split()
p_data = []
p_data.append(dat[0])
for x in dat[1:]:
p_data.append(int(x))
whole_data.append(p_data)
print(whole_data)
#???... |
s500271573 | p00661 | u546285759 | 1491192425 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | while True:
n, m = map(int, input().split())
if n == 0:
break
flag = 1
for i in range(m):
if int(input()) == 1:
flag = 0
print('{:.10f}'.format(n/2 if flag else 0)) |
s129996966 | p00661 | u633068244 | 1399377642 | Python | Python | py | Runtime Error | 20 | 4240 | 232 | while 1:
n,m = map(int,raw_input().split())
if n == 0: break
p = map(int,raw_input().split())
sp = set()
for pi in p: sp |= set([pi*j for j in range(1,n/pi+1)])
print (n*(n+1)/2-sum(sp))*1.0/(n-len(sp)) if n-len(sp) > 0 else 0 |
s013616837 | p00661 | u633068244 | 1399379639 | Python | Python | py | Runtime Error | 10 | 4440 | 694 | import itertools
def prdct(array):
ref = 1
for a in array: ref *= a
return ref
while 1:
n,m = map(int,raw_input().split())
if n == 0: break
p = sorted(map(int,raw_input().split()))
if 1 in p:
print 0.0
continue
for i in range(len(p)-1,0,-1):
for j in range(i):
while 1:
if p[i] == p[j]:
del p[... |
s592414572 | p00662 | u633068244 | 1399376434 | Python | Python | py | Runtime Error | 0 | 0 | 224 | while 1:
N = map(int,raw_input().split())
if sum(N) == 0: break
md,gg,go = N[0]+N[3],N[1]+N[4],N[2]+N[5]
mn = min(md,gg,go)
ans = 0
for i in range(max(0,w-2),w):
ans = max(ans,i+(md-i)/3+(gg-i)/3+(go-i)/3)
print ans |
s111072805 | p00664 | u633068244 | 1400142073 | Python | Python | py | Runtime Error | 0 | 0 | 374 | while 1:
r,c,q = map(int,raw_input().split())
if r == 0: break
R = [[0,0] for i in range(r)]
C = [[0,0] for i in range(r)]
for i in range(1,q+1):
A,B,order = map(int,raw_input().split())
if A == 0:
R[B] = [i,order]
else:
C[B] = [i,order]
ans = 0
for ri in range(r):
ans += sum(R[ri][1] if R[ri][0] >... |
s905133307 | p00670 | u041086527 | 1416069287 | Python | Python | py | Runtime Error | 0 | 0 | 600 | import bisect
while True:
n,S = map(int, raw_input().split())
if n == 0 and S == 0:
break
r = [input() for i in range(n)]
ans = 0
r.sort()
for i in range(n):
tmp = S - r[i] + 1
if (tmp <= 0):
ans += n - 1
else:
d = r[0:i] + r[i + 1:]
... |
s323784507 | p00670 | u041086527 | 1416069315 | Python | Python | py | Runtime Error | 0 | 0 | 600 | import bisect
while True:
n,S = map(int, raw_input().split())
if n == 0 and S == 0:
break
r = [input() for i in range(n)]
ans = 0
r.sort()
for i in range(n):
tmp = S - r[i] + 1
if (tmp <= 0):
ans += n - 1
else:
d = r[0:i] + r[i + 1:]
... |
s582049578 | p00670 | u041086527 | 1416069414 | Python | Python | py | Runtime Error | 0 | 0 | 586 | while True:
n,S = map(int, raw_input().split())
if n == 0 and S == 0:
break
r = [input() for i in range(n)]
ans = 0
r.sort()
for i in range(n):
tmp = S - r[i] + 1
if (tmp <= 0):
ans += n - 1
else:
d = r[0:i] + r[i + 1:]
left,rig... |
s375118333 | p00670 | u633068244 | 1399102157 | Python | Python | py | Runtime Error | 0 | 0 | 267 | R = 101
while 1:
n,S = map(int,raw_input().split())
if n == 0: break
r = [0]*R
for i in range(n):
r[int(raw_input())] += 1
ans = 0
for i in range(R):
if 2*i > S:
ans += r[i]*(r[i]-1)/2
ans += r[i]*sum([r[j] for j in range(max(i+1,S-j+1),R)])
print ans |
s625141861 | p00670 | u633068244 | 1399102416 | Python | Python | py | Runtime Error | 0 | 0 | 285 | R = 101
while 1:
n,S = map(int,raw_input().split())
if n == 0: break
d = [int(raw_input()) for i in range(n)]
r = [d.count(i) for i in set(d)]
ans = 0
for i in range(R):
if 2*i > S:
ans += r[i]*(r[i]-1)/2
ans += r[i]*sum([r[j] for j in range(max(i+1,S-i+1),R)])
print ans |
s098731759 | p00677 | u827448139 | 1417437517 | Python | Python | py | Runtime Error | 0 | 0 | 449 | while True:
s,d,m=map(int,input().split())
ws,ps=[0]*s,[0]*s
for i in range(s):
k=int(input())
tmp=list(map(int,input().split()))
ws[i],ps[i]=tmp[0::2],tmp[1::2]
f=list(map(int,input().split()));
dp=[0]*(m+1)
for i in f:
for p,w in zip(ps[i],ws[i]):
for x in reversed(range(p,m+1)):
... |
s436439590 | p00682 | u296492699 | 1404745977 | Python | Python | py | Runtime Error | 0 | 0 | 343 | c=0
while True:
n=input()
if n==0:
break
c+=1
a0, b0=map(int,raw_input().split())
prev_a, prev_b=a, b
tmp=0
for i in range(n):
a, b=map(int,raw_input().split())
tmp+=(a-prev_a)**2+(b-prev_b)**2
prev_a, prev_b=a, b
tmp+=(prev_a-a0)**2+(prev_b-b0)**2
pri... |
s103333148 | p00682 | u296492699 | 1404746028 | Python | Python | py | Runtime Error | 0 | 0 | 345 | c=0
while True:
n=input()
if n==0:
break
c+=1
a0, b0=map(int,raw_input().split())
prev_a, prev_b=a0, b0
tmp=0
for i in range(n):
a, b=map(int,raw_input().split())
tmp+=(a-prev_a)**2+(b-prev_b)**2
prev_a, prev_b=a, b
tmp+=(prev_a-a0)**2+(prev_b-b0)**2
p... |
s805579221 | p00682 | u296492699 | 1404747151 | Python | Python | py | Runtime Error | 0 | 0 | 332 | c=0
while True:
n=input()
if n==0:
break
c+=1
x0, y0=map(int,raw_input().split())
prev_x, prev_y=x0, y0
tmp=0
for i in range(n):
x,y=map(int,raw_input().split())
tmp+=prev_x*y - prev_y*x
prev_x, prev_y=x, y
tmp+=prev_x*y0 - prev_y*x0
print c, 0.5*abs(t... |
s306943555 | p00682 | u296492699 | 1404747301 | Python | Python | py | Runtime Error | 0 | 0 | 334 | c=0
while True:
n=input()
if n==0:
break
c+=1
x0, y0=map(int,raw_input().split())
prev_x, prev_y=x0, y0
tmp=0
for i in range(n-1):
x,y=map(int,raw_input().split())
tmp+=prev_x*y - prev_y*x
prev_x, prev_y=x, y
tmp+=prev_x*y0 - prev_y*x0
print c, 0.5*abs... |
s200677614 | p00682 | u296492699 | 1404747561 | Python | Python | py | Runtime Error | 0 | 0 | 346 | c=0
while True:
n=input()
if n==0:
break
c+=1
x0, y0=map(int,raw_input().split())
prev_x, prev_y=x0, y0
tmp=0
for i in range(n-1):
x,y=map(int,raw_input().split())
tmp+=prev_x*y - prev_y*x
prev_x, prev_y=x, y
tmp+=prev_x*y0 - prev_y*x0
print c, 0.5*abs... |
s211074087 | p00682 | u296492699 | 1404747675 | Python | Python | py | Runtime Error | 0 | 0 | 351 | c=0
while True:
n=input()
if n==0:
break
c+=1
x0, y0=map(int,raw_input().split())
prev_x, prev_y=x0, y0
tmp=0
for i in range(n-1):
x,y=map(int,raw_input().split())
tmp+=prev_x*y - prev_y*x
prev_x, prev_y=x, y
tmp+=prev_x*y0 - prev_y*x0
print c, 0.5*abs... |
s569358249 | p00682 | u809815599 | 1472307657 | Python | Python3 | py | Runtime Error | 0 | 0 | 25 | import numpy
import scipy |
s890458354 | p00682 | u809815599 | 1472307775 | Python | Python3 | py | Runtime Error | 0 | 0 | 27 | import numpy
print("hello") |
s172909969 | p00683 | u797673668 | 1488441672 | Python | Python3 | py | Runtime Error | 0 | 0 | 3178 | class TextEditor:
cur_w = 0
cur_c = 0
def __init__(self, txt):
self.words = txt.split(' ')
self.queries = {
'forward char': self.forward_char,
'forward word': self.forward_word,
'backward char': self.backward_char,
'backward word': self.backwa... |
s481326348 | p00683 | u104911888 | 1373879857 | Python | Python | py | Runtime Error | 0 | 0 | 1115 | for i in range(input()):
s=raw_input()
cur=0
for j in range(input()):
temp=raw_input()
cmd,obj=temp.replace('"',"").split()
if cmd=="forward":
if obj=="char":
cur+=1
cur=min(cur,len(s))
else:
while cur<len(s):
... |
s334709879 | p00683 | u104911888 | 1373881381 | Python | Python | py | Runtime Error | 0 | 0 | 1195 | for i in range(input()):
s=raw_input()
cur=0
for j in range(input()):
cmd=raw_input()
if cmd=="forward char":
cur=min(cur+1,len(s))
elif cmd=="forward word":
while cur<len(s) and s[cur]==" ":
cur+=1
while cur<len(s) and s[cur]!=" ":... |
s257534612 | p00683 | u104911888 | 1373881467 | Python | Python | py | Runtime Error | 0 | 0 | 1195 | for i in range(input()):
s=raw_input()
cur=0
for j in range(input()):
cmd=raw_input()
if cmd=="forward char":
cur=min(cur+1,len(s))
elif cmd=="forward word":
while cur<len(s) and s[cur]==" ":
cur+=1
while cur<len(s) and s[cur]!=" ":... |
s283229828 | p00683 | u858885710 | 1397896774 | Python | Python | py | Runtime Error | 0 | 0 | 1252 | def operate( cmd, text, cur ):
lentxt = len(text)
if cmd == "forward char":
if cur < lentxt: cur += 1
elif cmd == "backward char":
if cur > 0: cur -= 1
elif cmd == "forward word":
while cur < lentxt and text[cur] == ' ': cur += 1
while cur < lentxt and text[cur] != ' ': c... |
s767324038 | p00684 | u858885710 | 1397990496 | Python | Python | py | Runtime Error | 0 | 0 | 983 | i = 1j
s = None
while True:
try:
s = raw_input()
except EOFError:
break
k, len_s, overflow = 0, len(s), False
while k < len_s:
while k < len_s and not s[k].isdigit(): k += 1
begin = k
while k < len_s and s[k].isdigit(): k += 1
end = k
if begin == l... |
s140669451 | p00686 | u266872031 | 1385450326 | Python | Python | py | Runtime Error | 0 | 0 | 769 | import sys
checksize=0
place=[]
face=0 #N=0 E=1 S=2 W=3
X=0
Y=0
for l in sys.stdin:
line=l.split()
if checksize==0:
checksize=1
A=map(int,line)
X=A[0]
Y=A[1]
place=[1,1]
elif line[0]=="STOP":
checksize=0
elif line[0]=="LEFT":
face=(face-1)%4
... |
s311310134 | p00686 | u266872031 | 1385450468 | Python | Python | py | Runtime Error | 0 | 0 | 811 | import sys
checksize=0
place=[]
face=0 #N=0 E=1 S=2 W=3
X=0
Y=0
for l in sys.stdin:
line=l.split()
if checksize==0:
checksize=1
A=map(int,line)
X=A[0]
Y=A[1]
place=[1,1]
elif line[0]=="STOP":
checksize=0
print str(place[0])+" "+str(place[1])
elif ... |
s799492286 | p00686 | u266872031 | 1385465547 | Python | Python | py | Runtime Error | 0 | 0 | 811 | import sys
checksize=0
place=[]
face=0 #N=0 E=1 S=2 W=3
X=0
Y=0
for l in sys.stdin:
line=l.split()
if checksize==0:
checksize=1
A=map(int,line)
X=A[0]
Y=A[1]
place=[1,1]
elif line[0]=="STOP":
checksize=0
print str(place[0])+" "+str(place[1])
elif ... |
s982364121 | p00686 | u266872031 | 1385566719 | Python | Python | py | Runtime Error | 0 | 0 | 846 | import sys
checksize=0
place=[]
face=0 #N=0 E=1 S=2 W=3
X=0
Y=0
for l in sys.stdin:
line=l.split()
if line[0]==0:
break
elif checksize==0:
checksize=1
A=map(int,line)
X=A[0]
Y=A[1]
place=[1,1]
elif line[0]=="STOP":
checksize=0
print str(pl... |
s487108356 | p00687 | u847467233 | 1531529587 | Python | Python3 | py | Runtime Error | 0 | 0 | 218 | # AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u
while True:
n, a, b = map(int, input().split())
if n == 0: break
f = [0]*(n+1)
for x in range(0, n, a):
for y in range(0, n+1, b): f[x+y] = 1
print(n-sum(f))
|
s262371115 | p00687 | u847467233 | 1531529828 | Python | Python3 | py | Runtime Error | 0 | 0 | 225 | # AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u
while True:
n, a, b = map(int, input().split())
if n == 0: break
f = [0]*(n>>1)
for x in range(0, n, a):
for y in range(0, n+1, b): f[x+y] = 1
print(n-sum(f[1:n+1]))
|
s060796466 | p00687 | u633068244 | 1400321585 | Python | Python | py | Runtime Error | 0 | 0 | 215 | while 1:
n,a,b = map(int,raw_input().split())
if n == 0: break
dp = [0]*(n+1)
dp[a] = dp[b] = 1
for i in range(n+1):
if dp[i] == 1:
if i+a < n+1: dp[i+a] = 1
if i+b < n+1: dp[i+b] = 1
print n - sum(dp) |
s351385448 | p00687 | u633068244 | 1400322123 | Python | Python | py | Runtime Error | 0 | 0 | 201 | while 1:
n,a,b = map(int,raw_input().split())
if n == 0: break
dp = [0]*(max(n,a,b)+1)
dp[a] = dp[b] = 1
for i in range(n+1-min(a,b)):
if dp[i]:
dp[i+a] = dp[i+b] = 1
print n - sum(dp[:n+1]) |
s949290515 | p00688 | u797673668 | 1490618463 | Python | Python3 | py | Runtime Error | 0 | 0 | 406 | from math import gcd
while True:
a, b, c = map(int, input().split())
if not a:
break
d = (b ** 2 - 4 * a * c) ** 0.5
if isinstance(d, complex) or d - int(d) > 1e-6:
print('Impossible')
continue
num1, num2 = -b + int(d), -b - int(d)
den = 2 * a
cmn1, cmn2 = gcd(num1, ... |
s487984757 | p00691 | u633068244 | 1396535165 | Python | Python | py | Runtime Error | 0 | 0 | 147 | while 1:
n=input()**3
if n==0:break
mn=n
for i in range(1,n):
for j in range(i,n):
m=n-i**3-j**3
if m<0:break
if m<mn:mn=m
print mn |
s021356063 | p00691 | u633068244 | 1396536850 | Python | Python | py | Runtime Error | 0 | 0 | 150 | while 1:
z3=m=input()**3
if z3==0:break
x=0
while 1:
x+=1
x3=x**3
y=int((n3-i3)**(1/3.))
if y<x:break
n=z3-x3-y**3
if n<m:m=n
print m |
s714311728 | p00693 | u633068244 | 1400154015 | Python | Python | py | Runtime Error | 0 | 0 | 374 | import re
while 1:
n,m = map(int,raw_input().split())
P = []; D = []
for i in range(n):
p,s,d = raw_input().replace("?","[0-9]").split()
r = re.compile(s+d)
if p[0] == "p":
P.append(r)
else:
D.append(r)
for i in range(m):
s,d,name = raw_input().split()
tf = any(r.search(s+d) for r in P) and not an... |
s112134907 | p00698 | u647766105 | 1427981247 | Python | Python | py | Runtime Error | 0 | 0 | 1337 | from copy import deepcopy
answer = ""
while True:
line = raw_input()
while line.isspace() or not line: #!?!?!!!
line = raw_input()
if line == "0":
break
P, S = map(int, line.split())
def check(data):
return reduce(lambda a, b: a+b, data).count("?")
def calc(seq):
... |
s511165798 | p00705 | u046108504 | 1555867190 | Python | Python3 | py | Runtime Error | 0 | 0 | 368 | import collections
while True:
N, Q = map(int, input().split())
if N == 0 and Q == 0:
break
D = []
for _ in range(N):
i = list(map(int, input().split()))
del i[0]
[D.append(ii) for ii in i]
c = collections.Counter(D)
cc = c.most_common()
if cc[0][1] >= Q:
... |
s248635401 | p00705 | u546285759 | 1486804682 | Python | Python3 | py | Runtime Error | 0 | 0 | 383 | from collections import Counter
while 1:
N,Q=map(int,input().split())
if N==0: break
M,l=[list(map(int,input().split())) for _ in range(N)],[]
for mm in M:
if len(mm)!=1:
for i in range(1,len(mm)):
l.append(mm[i])
c=Counter(l)
_,mv=c.most_common(1)[0]
prin... |
s161863883 | p00705 | u546285759 | 1486804779 | Python | Python3 | py | Runtime Error | 0 | 0 | 383 | from collections import Counter
while 1:
N,Q=map(int,input().split())
if N==0: break
M,l=[list(map(int,input().split())) for _ in range(N)],[]
for mm in M:
if len(mm)!=1:
for i in range(1,len(mm)):
l.append(mm[i])
c=Counter(l)
_,mv=c.most_common(1)[0]
prin... |
s572096381 | p00705 | u546285759 | 1486804820 | Python | Python3 | py | Runtime Error | 0 | 0 | 391 | from collections import Counter
while 1:
N,Q=map(int,input().split())
if (N,Q)==(0,0): break
M,l=[list(map(int,input().split())) for _ in range(N)],[]
for mm in M:
if len(mm)!=1:
for i in range(1,len(mm)):
l.append(mm[i])
c=Counter(l)
_,mv=c.most_common(1)[0]
... |
s513648608 | p00705 | u546285759 | 1486804870 | Python | Python3 | py | Runtime Error | 0 | 0 | 398 | from collections import Counter
while 1:
N,Q=map(int,input().split())
if (N,Q)==(0,0): break
M,l=[list(map(int,input().split())) for _ in range(N)],[]
for mm in M:
if len(mm)!=1:
for i in range(1,len(mm)):
l.append(mm[i])
c=Counter(l)
_,mv=c.most_common(1)[0]
... |
s453051750 | p00705 | u146816547 | 1524749303 | Python | Python | py | Runtime Error | 0 | 0 | 364 | while True:
N, Q = map(int, raw_input().split())
if N == 0 and Q == 0:
break
t = [map(int, raw_input().split())[1:] for _ in range(N)]
table = [[i, 0] for i in range(10)]
for i in t:
for j in i:
table[j][1] += 1
table.sort(reverse=True, key=lambda x: x[1])
pr... |
s038284954 | p00705 | u109084363 | 1359198933 | Python | Python | py | Runtime Error | 0 | 0 | 610 | import sys
import collections
while True:
N, Q = map(int, sys.stdin.readline().split())
if N == 0:
break
counter = collections.Counter()
for i in xrange(N):
date = map(int, sys.stdin.readline().split())
if date[0] != 0:
counter.update(date[1:])
result = coun... |
s197974344 | p00705 | u104911888 | 1369792443 | Python | Python | py | Runtime Error | 0 | 0 | 236 | while True:
N,Q=map(int,raw_input().split())
if N==Q==0:break
T=[0]*51
for i in range(N):
L=map(int,raw_input().split())
for j in L[1:]:
T[j]+=1
m=max(T)
print 0 if m<Q else T.index(m) |
s592788340 | p00706 | u798803522 | 1468421119 | Python | Python3 | py | Runtime Error | 0 | 0 | 929 | trial = int(input())
while True:
area = [int(n) for n in input().split(" ")]
trees = []
for t in range(trial):
trees.append(int(n) for n in input().split(" "))
cnt,answer = 0,0
trees = sorted(trees,key=lambda x:(x[0],x[1]))
building = [int(n) for n in input().split(" ")]
for x in ran... |
s533947681 | p00706 | u798803522 | 1468423334 | Python | Python3 | py | Runtime Error | 0 | 0 | 1186 | with open("input1(1).txt") as files:
trial = int(files.readline())
while True:
area = [int(n) for n in files.readline().split(" ")]
trees = []
for t in range(trial):
trees.append([int(n) for n in files.readline().split(" ")])
cnt,answer = 0,0
trees = sorted(tr... |
s190017676 | p00706 | u506554532 | 1512979486 | Python | Python3 | py | Runtime Error | 0 | 0 | 637 | while True:
N = int(input())
if N == 0: break
W,H = map(int,input().split())
fld = [[0 for w in range(W)] for h in range(H)]
for i in range(N):
x,y = map(lambda s:int(s)-1,raw_input().split())
fld[y][x] = 1
cums = [[0 for w in range(W+1)] for h in range(H+1)]
for y in range(H... |
s154983868 | p00706 | u506554532 | 1512979560 | Python | Python3 | py | Runtime Error | 0 | 0 | 637 | while True:
N = int(input())
if N == 0: break
W,H = map(int,input().split())
fld = [[0 for w in range(W)] for h in range(H)]
for i in range(N):
x,y = map(lambda s:int(s)-1,raw_input().split())
fld[y][x] = 1
cums = [[0 for w in range(W+1)] for h in range(H+1)]
for y in range(H... |
s941015625 | p00708 | u633068244 | 1400158920 | Python | Python | py | Runtime Error | 0 | 0 | 599 | def R(xyrz,xyrz1):
x, y, z, r = xyrz
x1,y1,z1,r1 = xyrz1
return max(0,((x-x1)**2 + (y-y1)**2 + (z-z1)**2)**0.5 - r - r1)
while 1:
n = input()
if n == 0: break
xyzr = [map(float,raw_input().split()) for i in range(n)]
ans = 1e12
for i in range(n):
for j in range(i+1,n):
l = R(xyzr[i],xyzr[j])
if l < an... |
s817911233 | p00708 | u633068244 | 1400159008 | Python | Python | py | Runtime Error | 0 | 0 | 585 | def R(xyrz,xyrz1):
x, y, z, r = xyrz
x1,y1,z1,r1 = xyrz1
return max(0,((x-x1)**2 + (y-y1)**2 + (z-z1)**2)**0.5 - r - r1)
while 1:
n = input()
if n == 0: break
xyzr = [map(float,raw_input().split()) for i in range(n)]
ml = 1e12
for i in range(n):
for j in range(i+1,n):
l = R(xyzr[i],xyzr[j])
if l < ml:... |
s774901935 | p00708 | u633068244 | 1400159056 | Python | Python | py | Runtime Error | 0 | 0 | 603 | def R(xyrz,xyrz1):
x, y, z, r = xyrz
x1,y1,z1,r1 = xyrz1
return max(0,((x-x1)**2 + (y-y1)**2 + (z-z1)**2)**0.5 - r - r1)
while 1:
n = input()
if n == 0: break
xyzr = [map(float,raw_input().split()) for i in range(n)]
ans = 1e12
for i in range(n):
for j in range(i+1,n):
l = 1#R(xyzr[i],xyzr[j])
if l < ... |
s910356741 | p00708 | u633068244 | 1400159213 | Python | Python | py | Runtime Error | 0 | 0 | 605 | def R(xyzr1,xyzr2):
x1,y1,z1,r1 = xyzr1
x2,y2,z2,r2 = xyzr2
return max(0,((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)**0.5 - r1 - r2)
while 1:
n = input()
if n == 0: break
xyzr = [map(float,raw_input().split()) for i in range(n)]
ans = 1e10
for i in range(n):
for j in range(i+1,n):
l = R(xyzr[i],xyzr[j])
if ... |
s039742867 | p00708 | u633068244 | 1400159370 | Python | Python | py | Runtime Error | 0 | 0 | 605 | def R(xyzr1,xyzr2):
x1,y1,z1,r1 = xyzr1
x2,y2,z2,r2 = xyzr2
return max(0,((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)**0.5 - r1 - r2)
while 1:
n = input()
if n == 0: break
xyzr = [map(float,raw_input().split()) for i in range(n)]
ans = 1e10
for i in range(n):
for j in range(i+1,n):
l = R(xyzr[i],xyzr[j])
if ... |
s626351376 | p00708 | u633068244 | 1400159414 | Python | Python | py | Runtime Error | 0 | 0 | 583 | def R(xyzr1,xyzr2):
x1,y1,z1,r1 = xyzr1
x2,y2,z2,r2 = xyzr2
return max(0,((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)**0.5 - r1 - r2)
while 1:
n = input()
if n == 0: break
xyzr = [map(float,raw_input().split()) for i in range(n)]
ans = 1e10
for i in range(n):
for j in range(i+1,n):
l = R(xyzr[i],xyzr[j])
if ... |
s364294754 | p00708 | u633068244 | 1400159723 | Python | Python | py | Runtime Error | 0 | 0 | 639 | def R(xyzr1,xyzr2):
x1,y1,z1,r1 = xyzr1
x2,y2,z2,r2 = xyzr2
return max(0,((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)**0.5 - r1 - r2)
while 1:
n = input()
if n == 0: break
if n == 1:
print 0.0
continue
xyzr = [map(float,raw_input().split()) for i in range(n)]
ans = 1e10
for i in range(n):
for j in range(i+1,n)... |
s361047229 | p00710 | u966364923 | 1419218331 | Python | Python3 | py | Runtime Error | 0 | 0 | 289 | while True:
(n, r) = [int(x) for x in input().split()]
if n==0 and r==0:
exit()
cards = [n-i for i in range(n)]
for _ in range(r):
(p, c) = [int(x) for x in input().split()]
cards = cards[p-1:c] + cards[p-1:p-1+c] + cards[p-1+c:]
print(cards[0]) |
s721509319 | p00710 | u998188826 | 1441280809 | Python | Python | py | Runtime Error | 0 | 0 | 255 |
while True:
n, r = map(int, input().split())
if (n, r) == (0, 0):
break
cards = list(range(1, n+1))[::-1]
print(cards)
for i in range(r):
p, c = map(int, input().split())
cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]
print(cards[0]) |
s935510928 | p00710 | u488601719 | 1451131882 | Python | Python | py | Runtime Error | 0 | 0 | 359 | while True:
n, r = map(int, input().split())
if n == 0 and r == 0:
break
l = []
for i in range(1, n + 1):
l.append(i)
for i in range(0, r):
p, c = map(int, input().split())
tmp = l[len(l) - p + 1:len(l)]
del l[len(l) - p + 1:len(l)]
l[len(l) - c:len(... |
s228883470 | p00710 | u616098312 | 1466500361 | Python | Python3 | py | Runtime Error | 0 | 0 | 311 | x=0
while True:
sousa=input().sprit() #?????????
sousa=[int(sousa[0]),int(sousa[1])]
if sousa==[0,0]:break
yama=[]
for k in range(sousa[1]):yama.append(k+1)
yama=yama[::-1]
for r in range(sousa[1]):
[p,c]=input().sprit()
[p,c]=[int(p),int(c)]
yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-2]
print(yama[0]) |
s474932279 | p00710 | u616098312 | 1466500498 | Python | Python3 | py | Runtime Error | 0 | 0 | 307 | while True:
sousa=input().sprit() #?????????
sousa=[int(sousa[0]),int(sousa[1])]
if sousa==[0,0]:break
yama=[]
for k in range(sousa[0]):yama.append(k+1)
yama=yama[::-1]
for r in range(sousa[1]):
[p,c]=input().sprit()
[p,c]=[int(p),int(c)]
yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-2]
print(yama[0]) |
s910262628 | p00710 | u653710476 | 1466502177 | Python | Python3 | py | Runtime Error | 0 | 0 | 366 | first = input().split()
n = int(first[0])
r = int(first[1])
while n != 0 or r != 0:
i = 0
card = list(range(n))
while i < r:
sh = input().split()
p, c = list(map(int,sh))
card = card[p-1:p+c-2:] + card[0:p-2:] + card[p+c-1:n:]
i = i + 1
print(n - int(card[0]))
next = ... |
s149680011 | p00710 | u798803522 | 1468136132 | Python | Python3 | py | Runtime Error | 0 | 0 | 543 | cond = [int(n) for n in input().split(" ")]
while True:
case = []
cards = [n for n in range(1,cond[0] + 1)]
for c in range(cond[1]):
case = ([int(n) for n in input().split(" ")]
disp = cards[case[0]:case[0]+case[1]]
cards[case[0]:case[0]+case[1]] = cards[case[0]-case[1]:case[0]]
... |
s816116747 | p00710 | u798803522 | 1468136181 | Python | Python3 | py | Runtime Error | 0 | 0 | 542 | cond = [int(n) for n in input().split(" ")]
while True:
case = []
cards = [n for n in range(1,cond[0] + 1)]
for c in range(cond[1]):
case = [int(n) for n in input().split(" ")]
disp = cards[case[0]:case[0]+case[1]]
cards[case[0]:case[0]+case[1]] = cards[case[0]-case[1]:case[0]]
... |
s338045982 | p00710 | u963883732 | 1518517357 | Python | Python3 | py | Runtime Error | 0 | 0 | 366 | l = input()
L = l.split()
for i in range(len(L)):
L[i] = int(L[i])
while True:
if L[0] == 0:
break
a = [L[0]-number for number in range(L[0])]
for j in range(L[1]):
r = input()
R = r.split()
for k in range(len(R)):
R[k] = int(R[k])
b = []
b += a[R[0]-1:R[0]+R[1]-1]
b += a[:R[0]-1]
b += a[R[0]+R[1... |
s653586413 | p00710 | u500292616 | 1530624332 | Python | Python3 | py | Runtime Error | 0 | 0 | 379 | n=1
r=1
while n !=0 and r!=0:
n,r=input().split()
n,r=int(n),int(r)
card= [[int(i) for i in input().split()] for i in range(r)]
yama= list(range(n,0,-1))
for i in range(r):
p=card[i][0]
c=card[i][1]
x=yama[:p-1]
y=yama[p-1:p-1+c]
z=yama[p-1+c:]
... |
s641538142 | p00711 | u124909914 | 1426121130 | Python | Python3 | py | Runtime Error | 0 | 0 | 501 | def search(x, y, m):
if x >= len(m[0]) or y >= len(m):
return 0
if m[y][x] == '#':
return 0
m[y][x] = '#'
return 1 + search(x+1,y, m) + search(x-1,y,m) \
+ search(x,y+1,m) + search(x,y-1,m)
while True:
w, h = map(int, input().split())
if w == 0: break
room = []
... |
s464988959 | p00711 | u966364923 | 1427445776 | Python | Python3 | py | Runtime Error | 0 | 0 | 1211 | while True:
W,H = [int(x) for x in input().split()]
if W==0 and H==0:
exit()
tiles = []
X = 0
Y = 0
for i in range(H):
tiles.append(input())
if '@' in tiles[i]:
Y = i
X = tiles[i].index('@')
d = [[9999 for j in range(H*W)] for i in range(H*W)]
... |
s747321407 | p00711 | u667806071 | 1464097275 | Python | Python | py | Runtime Error | 0 | 0 | 812 | re = open("input")
count = 0
role = {".": True, "@": False, "#": False}
def now(xpoint, ypoint):
return role[room[ypoint][xpoint]]
def search(xpoint, ypoint):
global count
if 0 <= xpoint < wh[0] and 0 <= ypoint < wh[1] and now(xpoint, ypoint):
count += 1
room[ypoint][xpoint] = "@"
s... |
s387907789 | p00711 | u798803522 | 1469203070 | Python | Python3 | py | Runtime Error | 0 | 0 | 848 | def getter(targ,x,y):
#print(x,y,len(targ[0]),len(targ))
if 0 > x or x >= len(targ) or 0 > y or y >= len(targ[0]) or targ[x][y] == '#':
return 0
else:
targ[x][y] = '#'
return 1 + getter(targ,x+1,y) + getter(targ,x-1,y) + getter(targ,x,y+1) + getter(targ,x,y-1)
with open("input1.txt")... |
s027978566 | p00711 | u358919705 | 1481546272 | Python | Python3 | py | Runtime Error | 0 | 0 | 664 | data, res
def valid(x, y):
global data
return 0 <= x < W and 0 <= y < H and data[y][x] != '#'
def dfs(x, y):
global data, res
if valid(x, y):
res += 1
data[y][x] = '#'
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(4):
dfs(x + dx[i], y + dy[i])... |
s533503240 | p00711 | u358919705 | 1481546434 | Python | Python3 | py | Runtime Error | 0 | 0 | 652 | data, res
def valid(x, y):
global data
return 0 <= x < W and 0 <= y < H and data[y][x] != '#'
def dfs(x, y):
global data, res
if valid(x, y):
res += 1
data[y][x] = '#'
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(4):
dfs(x + dx[i], y + dy[i])... |
s297098570 | p00711 | u358919705 | 1481546533 | Python | Python3 | py | Runtime Error | 0 | 0 | 660 | data, res = [], 0
def valid(x, y):
global data
return 0 <= x < W and 0 <= y < H and data[y][x] != '#'
def dfs(x, y):
global data, res
if valid(x, y):
res += 1
data[y][x] = '#'
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(4):
dfs(x + dx[i], y ... |
s291409473 | p00711 | u635391238 | 1508564227 | Python | Python3 | py | Runtime Error | 0 | 0 | 1806 |
def depth_first_search(x, y):
"""
??±???????????¢?´¢?????????
:param x: ?????¨??°????¨?
:param y: ?????¨??°??????
:return: ?????°
"""
# ????????????????????§?¢??????????
# ??????x ,y+1
# ??????x+1,y
# ??????x ,y-1
# ??????x-1,y
move_list = [[0,1],[1,0],[0,-1],[-1,0]]
... |
s900394523 | p00711 | u228488524 | 1508828744 | Python | Python3 | py | Runtime Error | 0 | 0 | 724 | def search(M, l, walkable):
i, j = (l.pop(0))
nexts = []
if i !=0:
nexts.append((i-1, j))
if i != len(M)-1:
nexts.append((i+1, j))
if j != 0:
nexts.append((i, j-1))
if j != len(M[0])-1:
nexts.append((i, j+1))
for nex in nexts:
x, y = nex
if M[... |
s556463444 | p00711 | u228488524 | 1508829211 | Python | Python3 | py | Runtime Error | 0 | 0 | 723 | def search(M, l, walkable):
i, j = (l.pop(0))
nexts = []
if i !=0:
nexts.append((i-1, j))
if i != len(M)-1:
nexts.append((i+1, j))
if j != 0:
nexts.append((i, j-1))
if j != len(M[0])-1:
nexts.append((i, j+1))
for nex in nexts:
x, y = nex
if M[... |
s562147048 | p00711 | u228488524 | 1509429944 | Python | Python3 | py | Runtime Error | 0 | 0 | 729 | import queue
def solve(w, h):
q = queue.Queue()
m = [['#' for i in range(w+2)] for j in range(h+2)]
for i in range(h):
inp = input()
for j in range(w):
m[i+1][j+1] = inp[j]
if m[i+1][j+1] == '@':
start = [i+1,j+1]
q.put(start)
c = 1
while ... |
s722581822 | p00711 | u228488524 | 1512972253 | Python | Python3 | py | Runtime Error | 0 | 0 | 723 | def search(M, l, walkable):
i, j = (l.pop(0))
nexts = []
if i !=0:
nexts.append((i-1, j))
if i != len(M)-1:
nexts.append((i+1, j))
if j != 0:
nexts.append((i, j-1))
if j != len(M[0])-1:
nexts.append((i, j+1))
for nex in nexts:
x, y = nex
if M[... |
s517947745 | p00711 | u228488524 | 1512972667 | Python | Python3 | py | Runtime Error | 0 | 0 | 725 | def search(M, l, walkable):
i, j = (l.pop(0))
nexts = []
if i !=0:
nexts.append((i-1, j))
if i != len(M)-1:
nexts.append((i+1, j))
if j != 0:
nexts.append((i, j-1))
if j != len(M[0])-1:
nexts.append((i, j+1))
for nex in nexts:
x, y = nex
if M[... |
s368225366 | p00711 | u228488524 | 1512974039 | Python | Python3 | py | Runtime Error | 0 | 0 | 734 | def search(M, l, walkable):
i, j = (l.pop(0))
nexts = []
if i !=0:
nexts.append((i-1, j))
if i != len(M)-1:
nexts.append((i+1, j))
if j != 0:
nexts.append((i, j-1))
if j != len(M[0])-1:
nexts.append((i, j+1))
for nex in nexts:
x, y = nex
if M[... |
s901870521 | p00711 | u209989098 | 1529216678 | Python | Python3 | py | Runtime Error | 0 | 0 | 459 | while 1:
x,y = list(map(int,input()split()))
if x == 0:
break
pp = [1,-1,0,0]
qq = [0,0,1,-1]
m = []
for i in range(y):
m.append(list(input()))
if '@' in m[-1]:
ss = m[-1].index('@')
tt = i
cnt = 0
def move (cx,cy):
global cnt
if cy >= y or cy < 0 or cx >= x or cx < 0:
return
if m[cy][cx]... |
s896409084 | p00711 | u209989098 | 1529216711 | Python | Python3 | py | Runtime Error | 0 | 0 | 461 | while 1:
x,y = list(map(int,input()split()))
if x == 0:
break
pp = [1,-1,0,0]
qq = [0,0,1,-1]
m = []
for i in range(y):
m.append(list(input()))
if '@' in m[-1]:
ss = m[-1].index('@')
tt = i
cnt = 0
def move (cx,cy):
global cnt
if cy >= y or cy < 0 or cx >= x or cx < 0:
return 0
if m[cy][c... |
s244721465 | p00711 | u209989098 | 1529216865 | Python | Python3 | py | Runtime Error | 0 | 0 | 460 | while 1:
x,y = list(map(int,input().split()))
if x == 0:
break
pp = [1,-1,0,0]
qq = [0,0,1,-1]
m = []
for i in range(y):
m.append(list(input()))
if '@' in m[-1]:
ss = m[-1].index('@')
tt = i
cnt = 0
def move (cx,cy):
global cnt
if cy >= y or cy < 0 or cx >= x or cx < 0:
return
if m[cy][cx... |
s861849096 | p00711 | u209989098 | 1529216940 | Python | Python3 | py | Runtime Error | 0 | 0 | 462 | while 1:
x,y = list(map(int,input().split()))
if x == 0:
break
pp = [1,-1,0,0]
qq = [0,0,1,-1]
m = []
for i in range(y):
m.append(list(input()))
if '@' in m[-1]:
ss = m[-1].index('@')
tt = i
cnt = 0
def move (cx,cy):
global cnt
if cy >= y or cy < 0 or cx >= x or cx < 0:
return
if m[cy][cx... |
s563104688 | p00711 | u209989098 | 1529216956 | Python | Python3 | py | Runtime Error | 0 | 0 | 461 | while 1:
x,y = list(map(int,input().split()))
if x == 0:
break
pp = [1,-1,0,0]
qq = [0,0,1,-1]
m = []
for i in range(y):
m.append(list(input()))
if '@' in m[-1]:
ss = m[-1].index('@')
tt = i
cnt = 0
def move (cx,cy):
global cnt
if cy >= y or cy < 0 or cx >= x or cx < 0:
return
if m[cy][cx... |
s075045253 | p00711 | u500292616 | 1530672286 | Python | Python3 | py | Runtime Error | 0 | 0 | 1005 | # -*- coding: utf-8 -*-
#rea and blac
h,w=1,1
count=0
def search(x,y):
#マップの外側か壁の場合は何もしない
#print(x,y)
global count
if x<0 or x>w-1 or y<0 or y>h-1 or map_data[y][x]=='#':
return
#以前に到達していたら何もしない
if reached[y][x]:
return
reached[y][x]=1
count+=1
#pr... |
s964474388 | p00711 | u500292616 | 1530672307 | Python | Python3 | py | Runtime Error | 0 | 0 | 1005 | # -*- coding: utf-8 -*-
#rea and blac
h,w=1,1
count=0
def search(x,y):
#マップの外側か壁の場合は何もしない
#print(x,y)
global count
if x<0 or x>w-1 or y<0 or y>h-1 or map_data[y][x]=='#':
return
#以前に到達していたら何もしない
if reached[y][x]:
return
reached[y][x]=1
count+=1
#pr... |
s176034487 | p00711 | u500292616 | 1530684034 | Python | Python3 | py | Runtime Error | 0 | 0 | 1005 | # -*- coding: utf-8 -*-
#rea and blac
h,w=1,1
count=0
def search(x,y):
#マップの外側か壁の場合は何もしない
#print(x,y)
global count
if x<0 or x>w-1 or y<0 or y>h-1 or map_data[y][x]=='#':
return
#以前に到達していたら何もしない
if reached[y][x]:
return
reached[y][x]=1
count+=1
#pr... |
s323550655 | p00711 | u500292616 | 1530684069 | Python | Python3 | py | Runtime Error | 0 | 0 | 1005 | # -*- coding: utf-8 -*-
#rea and blac
h,w=1,1
count=0
def search(x,y):
#マップの外側か壁の場合は何もしない
#print(x,y)
global count
if x<0 or x>w-1 or y<0 or y>h-1 or map_data[y][x]=='#':
return
#以前に到達していたら何もしない
if reached[y][x]:
return
reached[y][x]=1
count+=1
#pr... |
s354542968 | p00711 | u617183767 | 1396838531 | Python | Python | py | Runtime Error | 0 | 0 | 1163 | # -*- coding: utf-8 -*-
count = 0
def dfs(i, j, island):
global count
print i, j
dxy = [(1, 0), (0, 1), (-1, 0), (0, -1)]
if i < 0 or i >= len(island) or j < 0 or j >= len(island[0]):
return
if island[i][j] == '#' or island[i][j] == 'x':
return
island[i][j] = 'x'
coun... |
s460079590 | p00711 | u617183767 | 1396838593 | Python | Python | py | Runtime Error | 0 | 0 | 1156 | # -*- coding: utf-8 -*-
count = 0
def dfs(i, j, island):
global count
#print i, j
dxy = [(1, 0), (0, 1), (-1, 0), (0, -1)]
if i < 0 or i >= len(island) or j < 0 or j >= len(island[0]):
return
if island[i][j] == '#' or island[i][j] == 'x':
return
island[i][j] = 'x'
cou... |
s915696254 | p00712 | u269391636 | 1523792797 | Python | Python3 | py | Runtime Error | 0 | 0 | 574 | from fractions import Fraction
def frac(n):
return(Fraction(1,n))
def part(s,a,n,m):
if s == 0:
return(1)
k = int(1/s)
if n == 1:
if frac(k) == s and k <= a:
return(1)
else:
return(0)
else:
ans = 0
for i in range(max(k,m),min(a,int(n/... |
s038192369 | p00712 | u779627195 | 1353169056 | Python | Python | py | Runtime Error | 0 | 0 | 490 | EPS = 10**(-8)
def f(i, cnt, total, prod):
global p,q,a,n
#print p,q,a,n
#print p/float(q), i, cnt, total, prod
if(abs(total-p/float(q))<EPS):
return 1
if(total+(n-cnt)*1.0/i+EPS<p/float(q) or p/float(q)<total-EPS
or cnt+1>n or prod*i>a):
return 0
return f(i,cnt+1,total+1... |
s999626458 | p00712 | u617183767 | 1400661851 | Python | Python | py | Runtime Error | 0 | 0 | 809 | # -*- coding: utf-8 -*-
def dfs(num, dem, k, cur_num, prd, p, q, a, n):
#print num, dem, k, cur_num, prd
#time.sleep(0.5)
if num == 0:
#print "result: " + str(result)
return 1
result = 0
i = cur_num
while prd * i <= a:
#print i, num, dem, k, cur_num, prd
if (n... |
s304224450 | p00712 | u617183767 | 1400661904 | Python | Python | py | Runtime Error | 0 | 0 | 798 | # -*- coding: utf-8 -*-
def dfs(num, dem, k, cur_num, prd, p, q, a, n):
#print num, dem, k, cur_num, prd
#time.sleep(0.5)
if num == 0:
#print "result: " + str(result)
return 1
result = 0
while prd * i <= a:
#print i, num, dem, k, cur_num, prd
if (n - k) * dem < n... |
s264335019 | p00712 | u617183767 | 1400662012 | Python | Python | py | Runtime Error | 0 | 0 | 813 | # -*- coding: utf-8 -*-
def dfs(num, dem, k, cur_num, prd, p, q, a, n):
#print num, dem, k, cur_num, prd
#time.sleep(0.5)
if num == 0:
#print "result: " + str(result)
return 1
result = 0
i = cur_num
while prd * i <= a:
#print i, num, dem, k, cur_num, prd
if (n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.