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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s484527072 | p00070 | u506132575 | 1417492533 | Python | Python | py | Runtime Error | 0 | 0 | 356 | import sys
import itertools
import time
start = time.time()
lis = []
for i in xrange(1,10):
count = 0
numbers = [0]*331
for e in itertools.permutations(range(10),i):
li = [ (j+1)*e[j] for j in xrange(len(e))]
numbers[sum(li)] += 1
lis.append(numbers)
for s in sys.stdin:
n,s = map(... |
s651668080 | p00070 | u160041984 | 1473905447 | Python | Python3 | py | Runtime Error | 0 | 0 | 313 | import sys
def line():return sys.stdin.readline().strip()
import itertools
k = (0,1,2,3,4,5,6,7,8,9)
for ln in line():
cnt = 0
n,s = map(int,ln.split())
for l in list(itertools.permutations(k,n)):
t = 0
for i in range(len(l)): t+=l[i] * (i + 1)
if t == s:cnt+=1
print(cnt) |
s857151566 | p00070 | u220324665 | 1476187806 | Python | Python3 | py | Runtime Error | 20 | 7372 | 221 | import sys
import itertools
for line in sys.stdin:
exit(1)
n,s=map(int,input().split())
cnt=0
for i in itertools.permutations(range(10),n):
sum=0
for j,k in enumerate(i):sum+=(j+1)*k
if sum==s:cnt+=1
print(cnt) |
s696051441 | p00070 | u277877982 | 1477896709 | Python | Python | py | Runtime Error | 0 | 0 | 537 | import sys
def oncount(x):
r=0
while x>0:
r+=x&1
x=x>>1
return r
dp=[[0]*331 for i in range(1024)]
for i in range(10):
dp[1<<i][i]=1
for i in range(1024):
for j in range(331):
t=oncount(i)
for k in range(10):
if 1&(i>>k):
x=j-t*k
... |
s577860344 | p00070 | u745277023 | 1484741848 | Python | Python3 | py | Runtime Error | 0 | 0 | 632 | import sys
def try_sum(xk=[], xn=xn): # x1 = n, x2 = k
xi = 0
for i in range(a):
xi += xn[i] * xk[i]
if xi == b:
total[0] += 1
def make_k(ceng=a):
i = 9
while i >= 0:
if ceng > 1:
gg[ceng - 1] = i
make_k(ceng - 1)
else:
gg[ceng... |
s724132742 | p00070 | u745277023 | 1484741940 | Python | Python3 | py | Runtime Error | 0 | 0 | 548 | import sys
def try_sum(xk=[], xn=xn):
xi = 0
for i in range(a):
xi += xn[i] * xk[i]
if xi == b:
total[0] += 1
def make_k(ceng=a):
i = 9
while i >= 0:
if ceng > 1:
gg[ceng - 1] = i
make_k(ceng - 1)
else:
gg[ceng - 1] = i
... |
s306161961 | p00070 | u078042885 | 1486076885 | Python | Python3 | py | Runtime Error | 0 | 0 | 278 | dp=[[0]*1001 for _ in range(11)]
u=[1]*10
def f(a,b):
dp[a][b]+=1
for i in range(10):
if u[i]:
u[i]=0
f(a+1,b+i*(a+1))
u[i]=1
f(0,0)
while 1:
try:n,s=map(int,input().split())
except:break
print([dp[n][s],0][s>330]) |
s300743153 | p00070 | u647766105 | 1356705524 | Python | Python | py | Runtime Error | 0 | 2872 | 613 | import sys
dp=[[[0]*341 for i in xrange((1<<10)+1)] for j in xrange(12)]
#dp[12][1025][340]
dp[0][0][0]=1
for i in xrange(10):
for j in xrange(1<<10):
for c in xrange(331):
if dp[i][j][c]==0:
continue
for k in xrange(10):
if (j>>k&1)==0:
... |
s747501402 | p00070 | u104911888 | 1370679699 | Python | Python | py | Runtime Error | 0 | 0 | 315 | import itertools
dp=[[0]*286 for i in range(10)]
for i in range(1,10):
t=range(1,1+i)
for j in itertools.permutations(range(10),i):
s=sum(l*k for l,k in zip(j,t))
dp[i][s]+=1
while True:
try:
n,s=map(int,raw_input().split())
except EOFError:
break
print dp[n][s] |
s506218246 | p00070 | u104911888 | 1370680249 | Python | Python | py | Runtime Error | 0 | 0 | 315 | import itertools
dp=[[0]*400 for i in range(10)]
for i in range(1,10):
t=range(1,1+i)
for j in itertools.permutations(range(10),i):
s=sum(l*k for l,k in zip(j,t))
dp[i][s]+=1
while True:
try:
n,s=map(int,raw_input().split())
except EOFError:
break
print dp[n][s] |
s285730936 | p00070 | u104911888 | 1370680398 | Python | Python | py | Runtime Error | 0 | 0 | 315 | import itertools
dp=[[0]*400 for i in range(11)]
for i in range(1,10):
t=range(1,1+i)
for j in itertools.permutations(range(10),i):
s=sum(l*k for l,k in zip(j,t))
dp[i][s]+=1
while True:
try:
n,s=map(int,raw_input().split())
except EOFError:
break
print dp[n][s] |
s641661289 | p00070 | u865312527 | 1372950255 | Python | Python | py | Runtime Error | 0 | 0 | 178 | import sys,itertools
for l in sys.stdin.readlines():
n,s=map(l.split())
ans=0
for d in itertools.combinations(range(10),n):
if sum(d)==s: ans+=1
print ans |
s121059734 | p00070 | u104911888 | 1386502744 | Python | Python | py | Runtime Error | 0 | 0 | 326 | dp = [[0] * 1024 for i in range(12)]
def dfs(bit, d, s):
dp[d][s] += 1
for i in range(10):
if bit & (1 << i):
dfs(bit - (1 << i), d + 1, s + (i * (d + 1)))
dfs((1 << 10) - 1,0,0)
while True:
try:
n, s=map(int, raw_input().split())
except EOFError:
break
print dp... |
s262884518 | p00070 | u514537648 | 1388596576 | Python | Python | py | Runtime Error | 0 | 0 | 960 | #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
... |
s335338485 | p00070 | u912237403 | 1392560128 | Python | Python | py | Runtime Error | 0 | 0 | 387 | import sys
def f0070(A,n,s):
if n==1:
if s in A: f=1
else f=0
return f
c=0
A=sorted(A)
A1=A[:n][::-1]
A2=A[-n:]
N=range(n)
def f(A):
return sum([(i+1)*A[i] for i in N])
if f(A1)<=s<=f(A2):
for i in range(len(A)):
b=s-A[i]*n
c+=f0070(A[:i]+A[i+1:],n-1,b)
return c
for a ... |
s829638280 | p00070 | u912237403 | 1392561012 | Python | Python | py | Runtime Error | 0 | 0 | 348 | import sys
def f0070(A,n,s):
if n==1:return s in A
A=sorted(A)
A1=A[:n+1][::-1]
A2=A[-n-1:]
b1=0
b2=0
c=0
for i in range(1,n+1):
b1+=i*A1[i]
b2+=i*A2[i]
if b1<=s<=b2:
for i in range(len(A)):
c+=f0070(A[:i]+A[i+1:],n-1,s-A[i]*n)
return c
for a in sys.stdin:
n,s=map(int,a.split())
... |
s853857633 | p00070 | u633068244 | 1393365039 | Python | Python | py | Runtime Error | 0 | 0 | 2697 | while True:
try:
count = 0
for i1 in range(10):
for i2 in range(10):
if i1 == i2:
continue
for i3 in range(10):
if i1==i3 or i2==i3:
continue
for i4 in range(10):
... |
s886811810 | p00070 | u912237403 | 1393719881 | Python | Python | py | Runtime Error | 0 | 0 | 599 | import sys
d0=[0]*1024
d1=[[0 for i in range(286)]for j in range(1024)]
B=[1,2,4,8,16,32,64,128,256,512]
def init():
global d
for i in range(1024):
binary=format(i,'b')
n0=binary.count('1')
d0[i]=n0
if n0==1:
d1[i][B.index(i)]=1
else:
for j in range(len(binary)):
dp=n0*j
... |
s765067275 | p00070 | u912237403 | 1393720254 | Python | Python | py | Runtime Error | 0 | 0 | 603 | import sys
d0=[0]*1024
d1=[[0 for i in range(286)]for j in range(1024)]
B=[1,2,4,8,16,32,64,128,256,512]
def init():
global d0,d1
for i in range(1024):
binary=format(i,'b')
n0=binary.count('1')
d0[i]=n0
if n0==1:
d1[i][B.index(i)]=1
else:
for j in range(len(binary)):
dp=n0*j... |
s731278755 | p00070 | u912237403 | 1393721268 | Python | Python | py | Runtime Error | 0 | 0 | 513 | import sys
K=1024
R=range(K)
B=[1,2,4,8,16,32,64,128,256,512]
C=[0]*K
D=[[0 for i in range(286)]for j in R]
def init():
global C,D
for i in R:
s=format(i,'b')
n=s.count('1')
C[i]=n
if n==1:D[i][B.index(i)]=1
else:
for j in range(len(s)):
if s[-j-1]=='1':
dp=n*j
... |
s820512886 | p00070 | u912237403 | 1393721421 | Python | Python | py | Runtime Error | 0 | 0 | 513 | import sys
K=1024
R=range(K)
B=[1,2,4,8,16,32,64,128,256,512]
C=[0]*K
D=[[0 for i in range(331)]for j in R]
def init():
global C,D
for i in R:
s=format(i,'b')
n=s.count('1')
C[i]=n
if n==1:D[i][B.index(i)]=1
else:
for j in range(len(s)):
if s[-j-1]=='1':
dp=n*j
... |
s767537441 | p00070 | u912237403 | 1393753671 | Python | Python | py | Runtime Error | 0 | 0 | 786 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;
int K=1024,N=331,B[]={1,2,4,8,16,32,64,128,256,512},C[1024]={0};
vvi D(K,vi(N));
int init(){
vi z(K);
for (int i=0;i<N;i++)z[i]=0;
for (int i=0;i<K;i++){
D[i] = z;
int tmp=i,tmp2=0,n=... |
s137159491 | p00070 | u633068244 | 1394728370 | Python | Python | py | Runtime Error | 0 | 0 | 537 | def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else: return 0
elif s-mx(9-m) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
... |
s248989973 | p00070 | u633068244 | 1394728419 | Python | Python | py | Runtime Error | 0 | 0 | 547 | def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(9-m) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return... |
s329840839 | p00070 | u633068244 | 1394728497 | Python | Python | py | Runtime Error | 0 | 0 | 537 | def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(9-m) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
... |
s807822124 | p00070 | u633068244 | 1394728638 | Python | Python | py | Runtime Error | 0 | 0 | 537 | def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(9-m) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
... |
s367552083 | p00070 | u633068244 | 1394728818 | Python | Python | py | Runtime Error | 0 | 0 | 539 | def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(9-m)-1 <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0... |
s683570679 | p00070 | u633068244 | 1394728833 | Python | Python | py | Runtime Error | 0 | 0 | 546 | def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(9-m)-1 <= sm and sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: r... |
s295141079 | p00070 | u633068244 | 1394728900 | Python | Python | py | Runtime Error | 0 | 0 | 539 | def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(n-m)-1 <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0... |
s395584223 | p00070 | u633068244 | 1394728947 | Python | Python | py | Runtime Error | 0 | 0 | 539 | def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(n-m)-1 <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0... |
s838988341 | p00070 | u633068244 | 1394729064 | Python | Python | py | Runtime Error | 0 | 0 | 537 | def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(n-m) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
... |
s387525370 | p00070 | u633068244 | 1394729250 | Python | Python | py | Runtime Error | 0 | 0 | 541 | def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(n-m+1)-1 <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
... |
s474289977 | p00070 | u633068244 | 1394729300 | Python | Python | py | Runtime Error | 0 | 0 | 541 | def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(n-m+1)-2 <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
... |
s355177680 | p00070 | u633068244 | 1394729318 | Python | Python | py | Runtime Error | 0 | 0 | 541 | def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(n-m+1)-5 <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
... |
s297713397 | p00070 | u633068244 | 1394729335 | Python | Python | py | Runtime Error | 0 | 0 | 539 | def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(n-m+2) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop(i)
... |
s851577704 | p00070 | u633068244 | 1394729431 | Python | Python | py | Runtime Error | 0 | 0 | 551 | def mx(ls,i):
if i == 0: return 0
else : return (i+1)*ls.pop()+ mx(i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(ls,n-m+1) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop... |
s800282649 | p00070 | u633068244 | 1394729450 | Python | Python | py | Runtime Error | 0 | 0 | 554 | def mx(ls,i):
if i == 0: return 0
else : return (i+1)*ls.pop()+ mx(i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(ls,n-m+1) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.pop... |
s207852010 | p00070 | u633068244 | 1394729469 | Python | Python | py | Runtime Error | 0 | 0 | 557 | def mx(ls,i):
if i == 0: return 0
else : return (i+1)*ls.pop()+ mx(ls,i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(ls,n-m+1) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
k = rls.... |
s841736256 | p00070 | u633068244 | 1394729491 | Python | Python | py | Runtime Error | 0 | 0 | 575 | def mx(ls,i):
rls = ls[:]
if i == 0: return 0
else : return (i+1)*rls.pop()+ mx(rls,i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(ls,n-m+1) <= sm <= s:
for i in range(9-m+1):
rls = ls[:]
... |
s396091129 | p00070 | u633068244 | 1394729891 | Python | Python | py | Runtime Error | 0 | 0 | 590 | def mx(ls,i):
rls = ls[:]
if i == 0 or len(rls) == 0: return 0
else : return (i+1)*rls.pop()+ mx(rls,i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(ls,n-m) <= sm <= s:
for i in range(9-m+1):
... |
s551880491 | p00070 | u633068244 | 1394730077 | Python | Python | py | Runtime Error | 0 | 0 | 590 | def mx(ls,i):
rls = ls[:]
if i <= 0 or len(rls) == 0: return 0
else : return (i+1)*rls.pop()+ mx(rls,i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s-mx(ls,n-m) <= sm <= s:
for i in range(9-m+1):
... |
s586835757 | p00070 | u633068244 | 1394730167 | Python | Python | py | Runtime Error | 0 | 0 | 599 | def mx(ls,i):
rls = ls[:]
if i <= 0 or len(rls) == 0: return 0
else : return (i+1)*rls.pop()+ mx(rls,i-1)
def cns(ls,m,sm):
global n, s
count = 0
if m == n:
if sm == s: return 1
else : return 0
elif s <= sm + mx(ls,n-m) and sm <= s:
for i in range(9-m+1):
... |
s910362455 | p00071 | u193025715 | 1407922501 | Python | Python3 | py | Runtime Error | 0 | 0 | 735 | n = int(input())
input()
for i in range(n):
board = [list(input()) for i in range(8)]
sx = int(input()) - 1
sy = int(input()) - 1
input()
board[sy][sx] == 2
bomb = []
n_bomb = [[sy, sx]]
points = []
for j in range(len(board)):
while '1' in board[j]:
px = board[j].index('1')
py = j
points.append([... |
s563486533 | p00071 | u586434734 | 1421751870 | Python | Python | py | Runtime Error | 0 | 0 | 1402 | #! /usr/bin/python
# -*- coding: utf-8 -*-
MAX_Y = 8
MAX_X = 8
def main():
# 入力
N = int(raw_input())
raw_input()
for i , j in enumerate(range(N)):
data = []
for j in range(MAX_Y):
input_list = map(int, raw_input())
data.append(input_list)
bomb_X = int(r... |
s692365470 | p00071 | u540744789 | 1427265824 | Python | Python | py | Runtime Error | 0 | 0 | 996 | def solve(data,p):
L=[]
if data[p[1]-1][p[0]-1]=="1":
data[p[1]-1]=data[p[1]-1][:p[0]-1]+"0"+data[p[1]-1][p[0]:]
L+=p
else:
return []
bakuhu=[(p[0]-3,p[1]),(p[0]-2,p[1]),(p[0]-1,p[1]),(p[0]+1,p[1]),(p[0]+2,p[1]),(p[0]+3,p[1]),(p[0],p[1]-3),(p[0],p[1]-2),(p[0],p[1]-1),(p[0],p[1]+1... |
s267390428 | p00071 | u140201022 | 1451299425 | Python | Python | py | Runtime Error | 0 | 0 | 600 | def bomb(f,x,y):
rf=f[:][:]
rf[y][x]=0
for i in [-3,-2,-1,1,2,3]:
if 0<=x+i<=7:
if rf[y][x+i]==1:
rf=bomb(rf,x+i,y)
if 0<=y+i<=7:
if rf[y+i][x]==1:
rf=bomb(rf,x,y+i)
return rf
n=int(raw_input())
for data in range(1,n+1):
raw_in... |
s253610170 | p00071 | u243900796 | 1465383408 | Python | Python3 | py | Runtime Error | 0 | 0 | 1645 | <?php
// ??????????????????????????????
function bomber($data, $x, $y){
if($x > 0 && $y > 0 && $x < 9 && $y < 9 && $data[$y][$x] > 0){
// ??????
$data[$y][$x] = 0;
// ?????????????????????????????????
for($i = 1; $i <= 3; $i++){
$data = bomber($data, $x-$i, $y);
$data = bomber($data, $x+$i, $y);
$dat... |
s190420505 | p00071 | u150984829 | 1520116520 | Python | Python3 | py | Runtime Error | 0 | 0 | 296 | def e(x,y):
A[y][x]='0'
for dx,dy in[(i,0),(0,i)for i in range(-3,4)]:
if 0<=x+dx<8 and 0<=y+dy<8 and A[y+dy][x+dx]=='1':e(x+dx,y+dy)
for i in range(int(input())):
print(f'Data {i+1}:')
input()
A=[list(input())for _ in[0]*8]
e(int(input())-1,int(input())-1)
for r in A:print(*r,sep='')
|
s795901338 | p00071 | u150984829 | 1520116542 | Python | Python3 | py | Runtime Error | 0 | 0 | 300 | def e(x,y):
A[y][x]='0'
for dx,dy in[(i,0),(0,i)for i in range(-3,4)if i]:
if 0<=x+dx<8 and 0<=y+dy<8 and A[y+dy][x+dx]=='1':e(x+dx,y+dy)
for i in range(int(input())):
print(f'Data {i+1}:')
input()
A=[list(input())for _ in[0]*8]
e(int(input())-1,int(input())-1)
for r in A:print(*r,sep='')
|
s617884877 | p00071 | u150984829 | 1520116655 | Python | Python3 | py | Runtime Error | 0 | 0 | 296 | def e(x,y):
A[y][x]='0'
for t in range(-3,4):
if 0<=x+dx<8 and A[y][x+dx]=='1':e(x+dx,y)
if 0<=y+dy<8 and A[y+dy][x]=='1':e(x,y+dy)
for i in range(int(input())):
print(f'Data {i+1}:')
input()
A=[list(input())for _ in[0]*8]
e(int(input())-1,int(input())-1)
for r in A:print(*r,sep='')
|
s778857436 | p00071 | u104911888 | 1368190486 | Python | Python | py | Runtime Error | 0 | 0 | 473 | x=[0,0,0,0,0,0,1,2,3,-1,-2,-3]
y=[1,2,3,-1,-2,-3,0,0,0,0,0,0]
def dfs(ty,tx):
if L[ty][tx]==1:
L[ty][tx]=0
for i,j in zip(x,y):
dx,dy=tx+i,ty+j
if 0<=dx<8 and 0<=dy<8:
dfs(dy,dx)
else:
return
n=input()
for i in range(n):
L=[map(int,raw_input(... |
s868863532 | p00071 | u104911888 | 1368190620 | Python | Python | py | Runtime Error | 0 | 0 | 459 | x=[0,0,0,0,0,0,1,2,3,-1,-2,-3]
y=[1,2,3,-1,-2,-3,0,0,0,0,0,0]
def dfs(ty,tx):
if L[ty][tx]==1:
L[ty][tx]=0
for i,j in zip(x,y):
dx,dy=tx+i,ty+j
if 0<=dx<8 and 0<=dy<8:
dfs(dy,dx)
return
n=input()
for i in range(n):
L=[map(int,raw_input()) for j in ra... |
s623735461 | p00071 | u104911888 | 1368190870 | Python | Python | py | Runtime Error | 0 | 0 | 461 | x=[0,0,0,0,0,0,1,2,3,-1,-2,-3]
y=[1,2,3,-1,-2,-3,0,0,0,0,0,0]
def dfs(ty,tx):
if L[ty][tx]==1:
L[ty][tx]=0
for i,j in zip(x,y):
dx,dy=tx+i,ty+j
if 0<=dx<=7 and 0<=dy<=7:
dfs(dy,dx)
return
n=input()
for i in range(n):
L=[map(int,raw_input()) for j in ... |
s237930625 | p00071 | u633068244 | 1394725104 | Python | Python | py | Runtime Error | 0 | 0 | 694 | def bomb(field,x,y):
rfield = field[:][:]
rfield[y][x] = 0
for i in range(-3,4):
if 0 <= x+i <= 7:
if rfield[y][x+i] == 1:
rfield = bomb(rfield,x+i,y)
if 0 <= y+i <= 7:
if rfield[y+i][x] == 1:
rfield = bomb(rfield,x,y+i)
return rfie... |
s382646751 | p00071 | u633068244 | 1394725155 | Python | Python | py | Runtime Error | 0 | 0 | 716 | def bomb(field,x,y):
rfield = field[:][:]
rfield[y][x] = 0
for i in range(-3,4):
if 0 <= x+i <= 7:
if rfield[y][x+i] == 1:
rfield = bomb(rfield,x+i,y)
if 0 <= y+i <= 7:
if rfield[y+i][x] == 1:
rfield = bomb(rfield,x,y+i)
return rfie... |
s769091279 | p00072 | u506132575 | 1417579201 | Python | Python | py | Runtime Error | 0 | 0 | 1723 | # http://ja.wikipedia.org/wiki/%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95
class vertex:
def __init__(self):
self.min_distance = float("inf")
self.distance = float("inf")
self.parent = None
self.minimum_adjacency_list = []
self.is_in_Q = True
self.is_in_V = False
def is_si... |
s131469400 | p00072 | u506132575 | 1417579357 | Python | Python | py | Runtime Error | 0 | 0 | 1381 | # http://ja.wikipedia.org/wiki/%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95
class vertex:
def __init__(self):
self.is_in_V = False
def is_single_in_V(v,p):
a = v[p[0]].is_in_V
b = v[p[1]].is_in_V
return ( a and not b ) or ( not a and b )
def all_in_V(v):
for e in v:
if not e.is_in_V:
... |
s359360609 | p00072 | u506132575 | 1417580291 | Python | Python | py | Runtime Error | 0 | 0 | 837 | def solve(nu,mu,du):
E = []
vs = [False]*nu
vs[0] = True
while True:
if all(vs):
break
min_dist,ind = float("inf"),float("inf")
for i in xrange(len(du)):
p_from = du[i][0]
p_to = du[i][1]
if vs[p_from] and vs[p_to]:
... |
s746668595 | p00072 | u506132575 | 1417580500 | Python | Python | py | Runtime Error | 0 | 0 | 835 | def solve(nu,mu,du):
E = []
vs = [False]*nu
vs[0] = True
while True:
min_dist,ind = float("inf"),float("inf")
for i in xrange(len(du)):
p_from = du[i][0]
p_to = du[i][1]
if vs[p_from] and vs[p_to]:
du.pop(i)
break
... |
s230112073 | p00072 | u462831976 | 1493338872 | Python | Python3 | py | Runtime Error | 0 | 0 | 888 | # -*- coding: utf-8 -*-
import sys
import os
for s in sys.stdin:
n = int(s)
if n == 0:
break
m = int(input())
# adjacency matrix
M = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(m):
a, b, d = map(int, input().split(','))
M[a][b] = d
M[b... |
s742985415 | p00072 | u912237403 | 1395489305 | Python | Python | py | Runtime Error | 0 | 0 | 337 | import sys
n=input()
N=range(n)
m=input()
A=[sys.maxint]*n
B=[A[:] for i in N]
A=[0]*n
C=[A[:] for i in N]
while 1:
s=raw_input()
if s=="0": break
a,b,w=map(int,s.split(","))
B[a][b],B[b][a]=w,w
s=0
for i in N:
x=min(B[i])
y=B[i].index(x)
if C[i][y]==0:
C[i][y],C[y][i]=1,1
s... |
s473938361 | p00072 | u633068244 | 1395925779 | Python | Python | py | Runtime Error | 0 | 0 | 330 | n,m = int(raw_input()),int(raw_input())
s = [map(int, raw_input().split(",")) for i in range(m)]
s = sorted(s, key=lambda x:x[2])
ls = range(n)
ref = ls[:]
ans = 0
for i in s:
x,y,d = s.pop(0)
a,b = ref[x],ref[y]
if a != b
for j in ls:
if ref[j] == a: ref[j] = b
ans += d/100 - 1
... |
s825931376 | p00073 | u606989659 | 1490777693 | Python | Python3 | py | Runtime Error | 0 | 0 | 180 |
import math
while True:
x = int(input())
h = int(input())
if x == h == 0:
break
S = (x ** 2) + 4(x * (math.sqrt((1 / 2) ** 2 + h ** 2 )))
print(S) |
s353110687 | p00073 | u606989659 | 1490779136 | Python | Python3 | py | Runtime Error | 0 | 0 | 154 | import math
x = int(input())
h = int(input())
if x == h == 0:
break
S = (x ** 2) + 4(x * (math.sqrt(((1 / 2) * x) ** 2 + h ** 2 )))
print(S) |
s010297807 | p00073 | u606989659 | 1490779426 | Python | Python3 | py | Runtime Error | 0 | 0 | 152 | import math
x = int(input())
h = int(input())
if x == h == 0:
break
S = (x ** 2) + 4(x * (math.sqrt((1 / 2) * x ** 2 + h ** 2 )))
print(S) |
s199059353 | p00073 | u150984829 | 1520117751 | Python | Python3 | py | Runtime Error | 0 | 0 | 81 | while 1:
x,h=int(input()),int(input())
if x:print(x*x+((x/2)**2+h**2)**.5*x*2)
|
s686219094 | p00074 | u489809100 | 1447226238 | Python | Python | py | Runtime Error | 0 | 0 | 724 | def doc_string():
"""
I can fly.
"""
while True:
h = int(raw_input) * 3600
m = int(raw_input) * 60
s = int(raw_input)
time = 120 * 60 - (h + m + s)
if h == -1 and m == -1 and s == -1:
print "kill"
h = str(time / 3600)
m = str(time % 3600 / 60)
s = str(time % 3600 % 6... |
s451386041 | p00074 | u150984829 | 1525254195 | Python | Python3 | py | Runtime Error | 0 | 0 | 146 | p=lambda x:print(f'{x//3600:02}:{x//60%60:02}:{x%60:02}')
for e in iter(input,'-1'):
h,m,s=map(int,e.split())
d=7200-h*3600-m*60-s
p(d);p(d*3)
|
s771984062 | p00074 | u150984829 | 1525254210 | Python | Python3 | py | Runtime Error | 0 | 0 | 148 | p=lambda x:print(f'{x//3600:02}:{x//60%60:02}:{x%60:02}')
for e in iter(input,'-1\n'):
h,m,s=map(int,e.split())
d=7200-h*3600-m*60-s
p(d);p(d*3)
|
s653944509 | p00074 | u912237403 | 1396271903 | Python | Python | py | Runtime Error | 0 | 0 | 201 | def f(t):
c,t=t%N,t/N
print "%02d:%02d:%02d"%(t/N,t%N,c)
return
while 1:
h,m,s=map(int,raw_input().split())
if [h,m,s]==[-1,-1,-1]: break
t=7200-(h*N+m)*N-s
f(t)
f(t*3) |
s163478571 | p00075 | u546285759 | 1482645658 | Python | Python3 | py | Runtime Error | 0 | 0 | 117 | import sys
for line in sys.stdin:
s, w, h = map(float, line.strip().split(","))
print(s if w / (h**2) >= 25) |
s637666008 | p00075 | u498511622 | 1501557976 | Python | Python3 | py | Runtime Error | 0 | 0 | 217 | total=0
s=0
i=0
try:
while True:
a,b = map(int,input().split(','))
total += a*b
s+=b
i+=1
except:
result=s/i+0.5
print(total)
if isinstance(result,float):
print(round(result))
else:
print(result) |
s829075998 | p00075 | u498511622 | 1501558073 | Python | Python3 | py | Runtime Error | 0 | 0 | 159 | total=0
s=0
i=0
try:
while True:
a,b = map(int,input().split(','))
total += a*b
s+=b
i+=1
except:
result=s/i+0.5
print(total)
print(round(result)) |
s700299661 | p00075 | u498511622 | 1501558167 | Python | Python3 | py | Runtime Error | 0 | 0 | 155 | total=s=i=0
try:
while True:
a,b = map(int,input().split(','))
total += a*b
s+=b
i+=1
except:
result=s/i+0.5
print(total)
print(round(result)) |
s587067536 | p00075 | u498511622 | 1501558226 | Python | Python3 | py | Runtime Error | 0 | 0 | 140 | total=s=i=0
try:
while True:
a,b = map(int,input().split(','))
total += a*b
s+=b
i+=1
except:
print(total)
print(round(s/i+0.5 )) |
s121433870 | p00075 | u498511622 | 1501558312 | Python | Python3 | py | Runtime Error | 0 | 0 | 146 | try:
total=s=i=0
while True:
a,b = map(int,input().split(','))
total += a*b
s += b
i += 1
except:
print(total)
print(round(s/i+0.5 )) |
s539940524 | p00075 | u498511622 | 1501558381 | Python | Python3 | py | Runtime Error | 0 | 0 | 145 | try:
total=s=i=0
while True:
a,b = map(int,input().split(','))
total += a*b
s += b
i += 1
except:
print(total)
print(round(s/i+0.5)) |
s370113902 | p00075 | u150984829 | 1525254501 | Python | Python3 | py | Runtime Error | 0 | 0 | 84 | for e in iter(input,'-1'):
s,w,h=e.split(',')
float(w)/float(h)**2<25 or print(s)
|
s994936417 | p00075 | u150984829 | 1525254514 | Python | Python3 | py | Runtime Error | 0 | 0 | 87 | for e in iter(input,'-1 -1'):
s,w,h=e.split(',')
float(w)/float(h)**2<25 or print(s)
|
s311515108 | p00075 | u136916346 | 1528351152 | Python | Python3 | py | Runtime Error | 0 | 0 | 133 | import sys
l=[list(map(float,i.split(","))) for i in sys.stdin]
bmi=lambda i:i[1]/(i[2]**2)
[print(int(i[0])) for i in l bmi(i)>=25]
|
s222566614 | p00075 | u912237403 | 1396385875 | Python | Python | py | Runtime Error | 0 | 0 | 131 | import sys
for s in sys.stdin:
s1=s.split(",")
n=int(s1[0])
h,w=map(float(s[1:]))
bmi=w/h^2
if bmi>=25: print n |
s074284606 | p00076 | u957021183 | 1505121825 | Python | Python3 | py | Runtime Error | 0 | 0 | 545 | # Aizu Problem 0076: Treasure Hunt II
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
positions = {0: [0, 0], 1: [1, 1]}
direction = 135 * math.pi / 180
x, y = 1, 1
for step in range(2, 10):
x += math.cos(direction)
y += ma... |
s161200916 | p00076 | u024715419 | 1519295031 | Python | Python3 | py | Runtime Error | 0 | 0 | 310 | import math
n = 7
x = [1 for i in range(n)]
y = [0 for i in range(n)]
ang = 0
for i in range(2, n):
ang += math.asin(1/math.sqrt(i - 1))
x[i] = x[i - 1] + math.cos(ang)
y[i] = y[i - 1] + math.sin(ang)
while True:
n = int(input())
if n == -1:
break
print(x[n])
print(y[n])
|
s233890068 | p00076 | u024715419 | 1519295050 | Python | Python3 | py | Runtime Error | 0 | 0 | 310 | import math
n = 7
x = [1 for i in range(n)]
y = [0 for i in range(n)]
ang = 0
for i in range(2, n):
ang += math.asin(1/math.sqrt(i - 1))
x[i] = x[i - 1] + math.cos(ang)
y[i] = y[i - 1] + math.sin(ang)
while True:
n = int(input())
if n == -1:
break
print(x[n])
print(y[n])
|
s570542989 | p00076 | u633068244 | 1393755620 | Python | Python | py | Runtime Error | 0 | 0 | 268 | import math
while True:
n = int(raw_input())
if n == -1:
break
r, theta = math.sqrt(2.0), pi/4.0
for i in range(1,n-1):
r = math.sqrt(r**2 + 1.0)
theta += math.asin(1.0/r)
print r*math.cos(theta)
print r*math.sin(theta) |
s942009146 | p00076 | u912237403 | 1396529596 | Python | Python | py | Runtime Error | 0 | 0 | 211 | A=[]
x=1.0
y=0.0
for i in range(101):
A.append([x,y])
tmp=(x**2+y**2)**.5
dx,dy=-y/tmp,x/tmp
x+=dx
y+=dy
while 1:
n=input()
if n==-1:break
a,b=A[n-1]
print "%.2f\n%.2f"%(a,b) |
s039526312 | p00077 | u504990413 | 1353501713 | Python | Python | py | Runtime Error | 0 | 0 | 429 | while True:
array = map(str,raw_input())
display = []
for i in range(len(array)):
if array[i] != '@':
display.append(array[i])
elif array[i] == '@':
insert = int(array[i+1])*array[i+2]
display.append(insert)
array[i+1] ,array[i+2]= '',''
... |
s358185711 | p00077 | u350508326 | 1373013019 | Python | Python | py | Runtime Error | 0 | 0 | 504 | text = []
ptext = []
while True:
try:
text = list(map(str,raw_input()))
# print text
f = 0
ptext = []
for i in range(len(text)):
if text[i] == '@':
# print text[i]
for k in range(int(text[i+1])-1):
ptext.appe... |
s472792959 | p00077 | u633068244 | 1393755979 | Python | Python | py | Runtime Error | 0 | 0 | 174 | while True:
inp = raw_input()
msg = ""
for i in range(len(inp)):
if inp[i] == "@": msg += inp[i+2]*int(inp[i+1])
else: msg += inp[i]
print msg |
s421569191 | p00077 | u633068244 | 1393756033 | Python | Python | py | Runtime Error | 0 | 0 | 170 | import sys
for inp sys.stdin:
msg = ""
for i in range(len(inp)):
if inp[i] == "@": msg += inp[i+2]*int(inp[i+1])
else: msg += inp[i]
print msg |
s356694033 | p00077 | u912237403 | 1396626598 | Python | Python | py | Runtime Error | 0 | 0 | 178 | import sys
for s in sys.stdin:
while 1:
p = s.find("@")
if p==-1: break
s = s.replace(s[p:p+3], s[p+2] * int(s[p+1]))
print s[:-1] |
s670815949 | p00078 | u519227872 | 1498837243 | Python | Python3 | py | Runtime Error | 0 | 0 | 534 | from sys import stdin
def sqmatrix(n):
return [[0] * n for i in range(n)]
def magicsq(m):
n = len(m)
j = n/2
i = j + 1
for num in range(1, n**2 + 1):
m[i][j] = num
i += 1
j += 1
i = i%n
j = j % n
if m[i][j] != 0:
i += 1
j -= 1
... |
s154909676 | p00078 | u633068244 | 1393758828 | Python | Python | py | Runtime Error | 0 | 0 | 504 | while True:
n = int(raw_input())
if n == 0:
break
magic = [[0 for i in range(n)] for i in range(n)]
x, y = n/2, n/2
magic[y][x] = 1
count = 2
while count <= n**2:
x, y = (x+1)%n, (y+1)%n
if magic[y][x] == 0:
magic[y][x] = count
count += 1
... |
s611122214 | p00079 | u529386725 | 1454781488 | Python | Python3 | py | Runtime Error | 0 | 0 | 333 | def cross(x, y):
return (x.conjugate() * y).imag
def area_polygon(points):
area = 0
n = len(points)
for i in range(n + 1):
area += cross(points[i], points[(i+1)%n])
return area / 2
import sys
p = []
for line in sys.stdin:
p.append(list(map(float, line.split(','))))
print(are... |
s827702449 | p00079 | u529386725 | 1454781597 | Python | Python3 | py | Runtime Error | 0 | 0 | 329 | def cross(x, y):
return (x.conjugate() * y).imag
def area_polygon(points):
area = 0
n = len(points)
for i in range(n):
area += cross(points[i], points[(i+1)%n])
return area / 2
import sys
p = []
for line in sys.stdin:
p.append(list(map(float, line.split(','))))
print(area_po... |
s640727921 | p00079 | u529386725 | 1454781701 | Python | Python3 | py | Runtime Error | 0 | 0 | 347 | def cross(x, y):
return (x.conjugate() * y).imag
def area_polygon(points):
area = 0
n = len(points)
for i in range(n):
area += cross(points[i], points[(i+1)%n])
return area / 2
import sys
p = []
for line in sys.stdin:
p.append(list(map(float, line.split(','))))
print("{0:06f... |
s566244561 | p00079 | u529386725 | 1454781872 | Python | Python3 | py | Runtime Error | 0 | 0 | 380 | def cross(x, y):
return (x.conjugate() * y).imag
def area_polygon(points):
area = 0
n = len(points)
for i in range(n):
area += cross(points[i], points[(i+1)%n])
return area / 2
import sys
p = []
for line in sys.stdin:
if line == "":
break
p.append(list(map(float, ... |
s380072150 | p00079 | u032662562 | 1489663842 | Python | Python3 | py | Runtime Error | 0 | 0 | 352 | def cross(x, y):
return (x.conjugate() * y).imag
def area_polygon(points):
area = 0
n = len(points)
for i in range(n):
area += cross(points[i], points[(i+1)%n])
return area / 2
import sys
p = []
for line in sys.stdin:
x, y = map(float, line.split(','))
p.append(x+y*1j... |
s474925575 | p00079 | u032662562 | 1489663878 | Python | Python3 | py | Runtime Error | 0 | 0 | 351 | def cross(x, y):
return (x.conjugate() * y).imag
def area_polygon(points):
area = 0
n = len(points)
for i in range(n):
area += cross(points[i], points[(i+1)%n])
return area / 2
import sys
p = []
for line in sys.stdin:
x, y = map(float, line.split(','))
p.append(x+y*j)... |
s919946638 | p00079 | u032662562 | 1489724648 | Python | Python3 | py | Runtime Error | 0 | 0 | 333 | import math
def op(u,v):
return (conjugate(u)*v).imag
f = []
while True:
try:
st = input().strip().split(',')
x,y = list(map(float,st ))
f.append(x + y*1j)
except EOFError:
break
s = 0.0
fo = f[0]
for j in range(2,len(f)):
i = j - 1
s += op(i-fo,j-fo)/2.0
print("%.6... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.