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(int,s.split())
print lis[n-1][s] |
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
if x>=0: dp[i][j]+=dp[i&~(1<<k)][x]
for a in sys.stdin
n,s=map(int,a.split())
ans=0
if s<=330:
for i in range(1024):
if oncount(i)==n:ans+=dp[i][s]
print ans |
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 - 1] = i
if len(list(set(gg))) == a:
try_sum(gg)
i -= 1
for xxx in sys.stdin:
a, b = map(int, xxx.split())
inp = "3 10"
a, b = inp.split()
a, b = int(a), int(b)
total = [0]
xn = list(range(1, a + 1))
gg = [0] * a
make_k()
print(total[0]) |
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
if len(list(set(gg))) == a:
try_sum(gg)
i -= 1
for xxx in sys.stdin:
a, b = map(int, xxx.split())
total = [0]
xn = list(range(1, a + 1))
gg = [0] * a
make_k()
print(total[0]) |
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:
dp[i+1][j|(1<<k)][(i+1)*k+c]+=dp[i][j][c]
ans=[[0]*341 for unused in xrange(12)]
for i in xrange(11):
for j in xrange(1<<10):
for c in xrange(331):
ans[i][c]+=dp[i][j][c]
for line in sys.stdin.readlines():
n,s=map(int,line.strip().split())
print ans[n][s] |
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[n][s] |
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;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int dp[11][331];
void rec(int bit,int d,int s)
{
dp[d][s]++;
for(int i=0;i<10;i++)
{
if(bit&(1<<i))rec(bit&~(1<<i),d+1,s+i*(d+1));
}
}
int main()
{
int n,s;
rec((1<<10)-1,0,0);
while(cin >> n >> s)
{
if(s>330)cout << 0 << endl;
else cout << dp[n][s] << endl;
}
return 0;
} |
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 in sys.stdin:
n,s=map(int,a.split())
print f0070(range(10),n,s) |
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())
print f0070(range(10),n,s) |
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):
if i1==i4 or i2==i4 or i3==i4:
continue
for i5 in range(10):
if i1==i5 or i2==i5 ori3==i5 or i4==i5:
continue
for i6 in range(10):
if i1==i6 or i2==i6 or i3==i6 or i4==i6 or i5==i6:
continue
for i7 in range(10):
if i1==i7 or i2==i7 or i3==i7 or i4==i7 or i5==i7:
continue
elif i6==i7:
continue
for i8 in range(10):
if i1==i8 or i2==i8 or i3==i8 or i4==i8 or i5==i8:
continue
elif i6==i8 or i7==i8:
continue
for i9 in range(10):
if i1==i9 or i2==i9 or i3==i9 or i4==i9 or i5==i9:
continue
elif i6==i9 or i7==i9 or i8==i9:
continue
for i10 in range(10):
if i1==i10 or i2==i10 or i3==i10 or i4==i10 or i5==i10:
continue
elif i6==i10 or i7==i10 or i8==i10 or i9==i10:
continue
wa = i1+2*i2+3*i3+4*i4+5*i5+6*i6+7*i7+8*i8+9*i9+10*i10
if s == wa:
check = ""
check += str(i1)+str(i2)+str(i3)+str(i4)+str(i5)
check += str(i6)+str(i7)+str(i8)+str(i9)+str(i10)
if check.find(0) == 11 - n:
count += 1
print count
except:
break |
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
if binary[-j-1]=='1':
i2=i-B[j]
for k in range(286-dp):
d1[i][k+dp]+=d1[i2][k]
return
def f0070(n,s):
x=sum([d1[i][s] for i in range(1024) if d0[i]==n])
return x
init()
for a in sys.stdin:
n,s=map(int,a.split())
print f0070(n,s) |
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
if binary[-j-1]=='1':
i2=i-B[j]
for k in range(286-dp):
d1[i][k+dp]+=d1[i2][k]
return
def f0070(n,s):
x=sum([d1[i][s] for i in range(1024) if d0[i]==n])
return x
init()
for a in sys.stdin:
n,s=map(int,a.split())
print f0070(n,s) |
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
i2=i-B[j]
for k in range(286-dp):
D[i][k+dp]+=D[i2][k]
return
init()
for a in sys.stdin:
n,s=map(int,a.split())
x=sum([D[i][s] for i in R if C[i]==n])
print x |
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
i2=i-B[j]
for k in range(331-dp):
D[i][k+dp]+=D[i2][k]
return
init()
for a in sys.stdin:
n,s=map(int,a.split())
x=sum([D[i][s] for i in R if C[i]==n])
print x |
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=0;
while (tmp){
n+=tmp&1;
tmp2++;
tmp/=2;
}
C[i]=n;
if(n==1)D[i][find(B,B+10,i)-B]=1;
else{
tmp = i;
for (int j=0;j<tmp2;j++){
if (tmp & 1){
int dp = n*j,i2=i-B[j];
for (int k=0;k<N-dp;k++)
D[i][k+dp]+=D[i2][k];
}
tmp/=2;
}
}
}
return 0;
}
int main(){
init();
int n,s,i,x;
while(1){
cin>>n>>s;
if(cin.eof())break;
x=0;
if(s<N)
for(i=0;i<N;i++)
if(C[i]==n)x+=D[i][s];
cout<<x<<endl;
}
} |
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
def mx(n):
if n == 0: return 0
else: return (n+1)*n + mx(n-1)
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else: print cns(ls,0,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 0
def mx(n):
if n == 0: return 0
else : return (n+1)*n + mx(n-1)
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,0) |
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
def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,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
def mx(i):
if i <= 0: return 0
else : return (i+1)*i + mx(i-1)
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,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
def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,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: return 0
def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,0) |
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
def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,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
def mx(i):
if i == 0: return 0
else : return (i+1)*i + mx(i-1)
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,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)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,0) |
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)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,0) |
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)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,0) |
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)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,0) |
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)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,0) |
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(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(n): print 0
else : print cns(ls,0,0) |
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(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(ls,n): print 0
else : print cns(ls,0,0) |
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.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(ls,n): print 0
else : print cns(ls,0,0) |
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[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(ls,n): print 0
else : print cns(ls,0,0) |
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):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(ls,n): print 0
else : print cns(ls,0,0) |
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):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(ls,n): print 0
else : print cns(ls,0,0) |
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):
rls = ls[:]
k = rls.pop(i)
count += cns(rls,m+1,sm+(m+1)*k)
return count
else: return 0
ls = [0,1,2,3,4,5,6,7,8,9]
while True:
n, s = map(int, raw_input().split())
if s > mx(ls,n): print 0
else : print cns(ls,0,0) |
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([py, px])
board[j][px] = '2'
while len(n_bomb) != 0:
bomb += n_bomb
n_bomb = []
for b in bomb:
for p in points:
if (p[0] == b[0] and b[1]-3 <= p[1] <= b[1]+3) or (p[1] == b[1] and b[0]-3 <= p[0] <= b[0]+3):
points.remove(p)
n_bomb.append(p)
ans = [['0'] * 8 for j in range(8)]
for p in points:
ans[p[0]][p[1]] = '1'
print("Data %s:" % str(i+1))
for p in ans:
print("".join(p)) |
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(raw_input())
bomb_Y = int(raw_input())
raw_input()
bomb_town = explosion(data, ((bomb_X-1, bomb_Y-1),))
print("Data " + str(i+1) + ":")
printBomb(bomb_town)
def printBomb(bomb):
for x in bomb:
print(reduce(lambda x, y: x+y, (map(str, x))))
# 盤面内か判定
def isIn(x, y):
return 0<=x<MAX_X and 0<=y<MAX_Y
# 爆弾を爆破
def explosion(data, bomb):
for b in bomb:
if data[b[1]][b[0]] == 1:
new_bomb = bom(data, b)
burned_data = burned(data, b)
data = explosion(burned_data, new_bomb)
return data
# 燃やす
def burned(data, b):
data[b[1]][b[0]] = 0
return data
# 燃焼範囲をチェック
def bom(data, b):
bom_area = [(-3, 0), (-2, 0), (-1, 0), (1, 0), (2, 0), (3, 0),
(0, -3), (0, -2), (0, -1), (0, 1), (0, 2), (0, 3)]
new_bomb = []
for x in bom_area:
bomb = tuple([sum(x) for x in zip(x,b)])
if isIn(*bomb):
new_bomb.append(bomb)
return new_bomb
if __name__=='__main__':
main() |
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),(p[0],p[1]+2),(p[0],p[1]+3)]
for i in range(len(bakuhu)):
if bakuhu[i][0]>0 and bakuhu[i][1] >0 and bakuhu[i][0] <9 and bakuhu[i][1] <9:
L.extend(solve(data,bakuhu[i]))
return L
while True:
ndata=input()
for i in range(ndata):
raw_input()
data=[]
for j in range(8):
data.append(raw_input())
x=input()
y=input()
p=(x,y)
L=solve(data,p)
while len(L)!=0:
x=L.pop(0)
y=L.pop(0)
data[y-1]=data[y-1][:x-1]+'0'+data[y-1][x:]
print "Data"+str(i+1)+':'
for i in range(len(data)):
print data[i]
|
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_input()
f=[]
for i in range(8):
l.append([int(x) for x in raw_input()])
x=int(raw_input())-1
y=int(raw_input())-1
# map(int,raw_input().split())
f=bomb(f,x,y)
print "Data %d:"%(data)
for i in range(8):
print ''.join(map(str, f[i])) |
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);
$data = bomber($data, $x, $y-$i);
$data = bomber($data, $x, $y+$i);
}
}
return $data;
}
// ????????????????????°??????
$count = intval(fgets(STDIN));
$dataset = array(); // ????????????????????¨???????????????
$total = 11 * $count; // ???????????§??\?????????????¨???????????????????????????????????????????11??????????????????+8???+x??§?¨?+y??§?¨?
$now = 0; // ?????????????????????????????????????¨??????¨
while($line = fgets(STDIN)){
$line = trim($line);
// ???????????????????????????????????????????¨????
if($line == ""){
$now++;
$dataset[$now] = array();
$col = 1;
}else{
if($col == 10){
// y??§?¨?
$dataset[$now]["y"] = intval($line);
}else if($col == 9){
// x??§?¨?
$dataset[$now]["x"] = intval($line);
$col++;
}else{
$dataset[$now][$col] = array();
for($row = 1; $row <= 8; $row++){
$dataset[$now][$col][$row] = intval(substr($line, $row-1, 1));
}
$col++;
}
}
$total--;
if($total < 1) break;
}
foreach($dataset as $key => $data){
// ??????????????????????????????????????????
$x = $data["x"];
$y = $data["y"];
// ??????????????????????¶????
unset($data["x"]);
unset($data["y"]);
// ???????????????
$data = bomber($data, $x, $y);
echo "Data {$key}:\n";
foreach($data as $row){
echo implode($row)."\n";
}
} |
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()) for j in range(8)]
ax,ay=input(),input()
dfs(ay-1,ax-1)
print "Data %d:"%(i+1)
for j in range(8):
print "".join(map(str,L[j])) |
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 range(8)]
ax,ay=input(),input()
dfs(ay-1,ax-1)
print "Data %d:"%(i+1)
for j in range(8):
print "".join(map(str,L[j])) |
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 range(8)]
ax,ay=input(),input()
dfs(ay-1,ax-1)
print "Data %d:"%(i+1)
for j in range(8):
print "".join(map(str,L[j])) |
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 rfield
n = int(raw_input())
for data in range(1,n+1):
# read condition
field = []
for line in range(8):
field.append(map(int, list(raw_input())))
x = int(raw_input())-1
y = int(raw_input())-1
# bombing!
field = bomb(field,x,y)
# print result
print "Data %d:"%(data)
for i in range(8):
print "".join(map(str, field[i])) |
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 rfield
n = int(raw_input())
for data in range(1,n+1):
# read condition
dammy = raw_input
field = []
for line in range(8):
field.append(map(int, list(raw_input())))
x = int(raw_input())-1
y = int(raw_input())-1
# bombing!
field = bomb(field,x,y)
# print result
print "Data %d:"%(data)
for i in range(8):
print "".join(map(str, field[i])) |
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_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:
return False
return True
def add_in_V(v,d):
v[d[0]].is_in_V = True
v[d[1]].is_in_V = True
def remove_all_in_V_pass(v,d):
for i in xrange(len(d)):
try:
if v[d[i][0]].is_in_V and v[d[i][1]].is_in_V:
d.pop(i)
except:
pass
def solve(nu,mu,du):
V= []
E = []
vertexes = [vertex() for i in xrange(nu)]
vertexes[0].distance = 0
V.append(vertexes[0])
vertexes[0].is_in_V = True
distances = [ e[2] for e in du ]
passess = [ e[0:2] for e in du]
while True:
if all_in_V(vertexes):
break
min_dist = float("inf")
ind = float("inf")
for i in xrange(len(du)):
pas = passess[i]
if is_single_in_V(vertexes,pas):
if min_dist > du[i][2]:
min_dist = du[i][2]
ind = i
E.append(min_dist)
add_in_V(vertexes,du[ind])
du.pop(ind)
remove_all_in_V_pass(vertexes,du)
print sum(E)/100 - len(E)
while True:
n = input()
if n == 0:
exit()
m = input()
data = []
for i in xrange(n):
data.append( map(int,raw_input().split(",")) )
solve(n,m,data) |
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:
return False
return True
def add_in_V(v,d):
v[d[0]].is_in_V = True
v[d[1]].is_in_V = True
def remove_all_in_V_pass(v,d):
for i in xrange(len(d)):
try:
if v[d[i][0]].is_in_V and v[d[i][1]].is_in_V:
d.pop(i)
except:
pass
def solve(nu,mu,du):
E = []
vertexes = [vertex() for i in xrange(nu)]
vertexes[0].is_in_V = True
while True:
if all_in_V(vertexes):
break
min_dist,ind = float("inf"),float("inf")
for i in xrange(len(du)):
if is_single_in_V(vertexes,du[i][0:2]):
if min_dist > du[i][2]:
min_dist = du[i][2]
ind = i
E.append(min_dist)
add_in_V(vertexes,du[ind])
du.pop(ind)
remove_all_in_V_pass(vertexes,du)
print sum(E)/100 - len(E)
while True:
n = input()
if n == 0:
exit()
m = input()
data = []
for i in xrange(n):
data.append( map(int,raw_input().split(",")) )
solve(n,m,data) |
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]:
du.pop(i)
continue
if ( vs[p_from] and not vs[p_to] ) or ( not vs[p_from] and vs[p_to]):
if min_dist > du[i][2]:
min_dist,ind,pf,pt = du[i][2],i,p_from,p_to
E.append(min_dist)
vs[pf] = vs[pt] = True
du.pop(ind)
print sum(E)/100 - len(E)
while True:
n = input()
if n == 0:
exit()
m = input()
data = []
for i in xrange(m):
data.append( map(int,raw_input().split(",")) )
solve(n,m,data) |
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
if ( vs[p_from] and not vs[p_to] ) or ( not vs[p_from] and vs[p_to]):
if min_dist > du[i][2]:
min_dist,ind,pf,pt = du[i][2],i,p_from,p_to
E.append(min_dist)
vs[pf] = vs[pt] = True
du.pop(ind)
if all(vs):
break
print sum(E)/100 - len(E)
while True:
n = input()
if n == 0:
exit()
m = input()
data = []
for i in xrange(m):
data.append( map(int,raw_input().split(",")) )
solve(n,m,data) |
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][a] = d
for i in range(m):
M[i][i] = 0
X = []
Y = [i for i in range(n)]
X.append(0)
Y.remove(0)
light_num = 0
while len(X) != n:
lst = []
for x in X:
for y in Y:
dist = M[x][y]
lst.append((dist, x, y))
lst.sort()
# selected node
dist, x, y = lst[0]
light_num += (dist // 100) - 1
if x not in X:
X.append(x)
Y.remove(x)
else:
X.append(y)
Y.remove(y)
print(light_num) |
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+=x/100-1
print 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
print ans |
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 % 60)
if len(h) == 1:
h = "0" + h
if len(m) == 1:
m = "0" + m
if len(s) == 1:
s = "0" + s
print h + ":" + m + ":" + s
h = str(time * 3 / 3600)
m = str(time * 3 % 3600 / 60)
s = str(time * 3 % 3600 % 60)
if len(h) == 1:
h = "0" + h
if len(m) == 1:
m = "0" + m
if len(s) == 1:
s = "0" + s
print h + ":" + m + ":" + s |
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 += math.sin(direction)
positions[step] = [x, y]
direction = math.atan2(x, -y)
while True:
n = int(input())
if n == -1:
break
print("%.2f" % positions[n-1][0])
print("%.2f" % positions[n-1][1])
|
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]= '',''
for i in range(len(display)-1):
display[i+1] = display[i]+ display[i+1]
print display[-1] |
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.append(text[i+2])
f = 1
else:
if f == 0:
ptext.append(text[i])
else:
f = 0 |
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
if j < 0:
j = n -1
i = i % n
return m
for line in stdin:
n = int(line)
if n == 0:
break
sm = sqmatrix(n)
for row in magicsq(sm): print (' '.join(map(str,row))) |
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
else:
x, y = (x-1)%n, (y+1)%n
magic[y][x] = count
count += 1
for i in xrange(n):
print "".join(map(lambda s:str(s).rjust(4),board[i]) |
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(area_polygon(p)) |
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_polygon(p)) |
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}".format(area_polygon(p))) |
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, line.split(','))))
print("{0:06f}".format(area_polygon(p))) |
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))
print(abs(area_polygon(p))) |
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))
print(abs(area_polygon(p))) |
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("%.6f" % abs(ss)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.