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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s110089845 | p01274 | u509278866 | 1535515958 | Python | Python3 | py | Runtime Error | 0 | 0 | 2325 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... |
s015821806 | p01283 | u633068244 | 1423406128 | Python | Python | py | Runtime Error | 19930 | 4448 | 627 | import math
def calcH(O):
n = len(O)
return sum(-O.count(x)*1.0/n*math.log(O.count(x)*1.0/n) for x in set(O))
M = 256
while 1:
n = int(raw_input())
if n == 0: break
I = map(int,raw_input().split())
H = 10**10
for S in range(16):
for A in range(16):
for C in range(16)... |
s947855374 | p01283 | u633068244 | 1423406354 | Python | Python | py | Runtime Error | 19930 | 4448 | 623 | import math
def calcH(O):
n = len(O)
return sum(-O.count(x)*1.0/n*math.log(O.count(x)*1.0/n) for x in set(O))
M = 256
while 1:
n = int(raw_input())
if n == 0: break
I = map(int,raw_input().split())
H = 10**10
for S in range(16):
for A in range(16):
for C in range(16):
... |
s899995885 | p01283 | u633068244 | 1423582029 | Python | Python | py | Runtime Error | 19930 | 4452 | 623 | import math
def calcH(O):
n = len(O)
return sum(-O.count(x)*1.0/n*math.log(O.count(x)*1.0/n) for x in set(O))
M = 256
while 1:
n = int(raw_input())
if n == 0: break
I = map(int,raw_input().split())
H = 10**10
for S in range(16):
for A in range(16):
for C in range(16):
... |
s956835244 | p01283 | u633068244 | 1423683665 | Python | Python | py | Runtime Error | 19930 | 4444 | 576 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 10**10
l = map(int,raw_input().split())
for S in range(16):
for A in range(16):
for C in range(16):
R = S
O = [0]*N
for i in range(N):
R = (A... |
s917761598 | p01283 | u633068244 | 1423684110 | Python | Python | py | Runtime Error | 0 | 0 | 598 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1
l = map(int,raw_input().split())
for S in range(16):
for A in range(16):
for C in range(16):
R = S
O = [0]*N
for i in range(N):
R = (A*R+C)... |
s698212365 | p01283 | u633068244 | 1423684194 | Python | Python | py | Runtime Error | 0 | 0 | 603 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1
l = map(int,raw_input().split())
for S in range(16):
for A in range(16):
for C in range(16):
R = S
O = [0]*N
for i in range(N):
R = (A*R+C)... |
s329585870 | p01283 | u633068244 | 1423684234 | Python | Python | py | Runtime Error | 19930 | 4452 | 606 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1e32
l = map(int,raw_input().split())
for S in range(16):
for A in range(16):
for C in range(16):
R = S
O = [0]*N
for i in range(N):
R = (A*R... |
s460160136 | p01283 | u633068244 | 1423684399 | Python | Python | py | Runtime Error | 19930 | 4456 | 608 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1e10
l = map(int,raw_input().split())
for S in range(16):
for A in range(16):
for C in range(16):
R = S
O = [0]*N
for i in range(N):
R = (A*R... |
s663478804 | p01283 | u506554532 | 1514525929 | Python | Python3 | py | Runtime Error | 0 | 0 | 753 | import math
from collections import Counter
M = 256
def entropy(ctr):
ret = 0
for v in ctr.values():
ret -= (v / N) * math.log2(v / N)
return ret
while True:
N = int(input())
if N == 0: break
src = list(map(int,input().split()))
ans_h = float('inf')
ans_sac = None
for s in ... |
s207398163 | p01283 | u506554532 | 1514526354 | Python | Python3 | py | Runtime Error | 0 | 0 | 850 | import math
from collections import Counter
M = 256
def entropy(ctr):
ret = 0
for v in ctr.values():
ret -= (v / N) * math.log2(v / N)
return ret
def solve(src):
ans_h = float('inf')
ans = None
for s in range(16):
for a in range(16):
for c in range(16):
... |
s884760562 | p01283 | u506554532 | 1514527275 | Python | Python3 | py | Runtime Error | 0 | 0 | 939 | import math
from collections import Counter
M = 256
def entropy_if_smallest(ctr,bound):
ret = 0
for v in ctr.values():
ret -= (v / N) * math.log2(v / N)
if ret >= bound:
return None
return ret
def solve(src):
ans_h = float('inf')
ans = None
for s in range(16):
... |
s768989767 | p01283 | u109084363 | 1364107899 | Python | Python | py | Runtime Error | 20000 | 5376 | 796 | import sys
import collections
import math
while True:
N = int(raw_input())
if N == 0:
break
I = map(int, raw_input().split())
M = 256
result = []
for S in xrange(16):
for A in xrange(16):
for C in xrange(16):
R = [S]
for i in xran... |
s097259227 | p01283 | u109084363 | 1364108098 | Python | Python | py | Runtime Error | 20000 | 5372 | 734 | import sys
import collections
import math
while True:
N = int(raw_input())
if N == 0:
break
I = map(int, raw_input().split())
M = 256
result = []
for S in xrange(16):
for A in xrange(16):
for C in xrange(16):
R = [S]
for i in xran... |
s306908574 | p01283 | u109084363 | 1364108172 | Python | Python | py | Runtime Error | 20000 | 5376 | 595 | import sys
import collections
import math
while True:
N = int(raw_input())
if N == 0:
break
I = map(int, raw_input().split())
M = 256
result = []
for S in xrange(16):
for A in xrange(16):
for C in xrange(16):
R = [S]
for i in xrange(N):
R.append((A * R[i] + C) % M)
O = []
for i in x... |
s464343296 | p01283 | u109084363 | 1364108425 | Python | Python | py | Runtime Error | 20000 | 5360 | 770 | import sys
import collections
import math
while True:
N = int(raw_input())
if N == 0:
break
I = map(int, raw_input().split())
M = 256
result = []
for S in xrange(16):
for A in xrange(16):
for C in xrange(16):
R = [S]
for i in xran... |
s289214529 | p01283 | u104911888 | 1372862233 | Python | Python | py | Runtime Error | 0 | 0 | 705 | import math
def prodR(s,a,c,N):
R=[s]
for i in range(1,N+1):
R.append((a*R[i-1]+c)%256)
return R[1:]
def entropy(R,I,N):
O=[(I[i]+R[i])%256 for i in range(N)]
L=[0]*256
for i in O:
L[i]+=1
H=-sum(float(L[i])/N*math.log(float(L[i])/N,2) for i in range(256) if L[i]!\
=0)
r... |
s522259215 | p01288 | u408260374 | 1519050377 | Python | Python3 | py | Runtime Error | 0 | 0 | 1727 | class UnionFindTree:
"""Disjoint-Set Data Structure
Union-Find Tree
complexity:
init: O(n)
find, unite, same: O(alpha(n))
used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ)
"""
def __init__(self, n):
self.par = list(range(n)) # parent
self.rank = [0] * n... |
s062456607 | p01288 | u072053884 | 1519139511 | Python | Python3 | py | Runtime Error | 0 | 0 | 763 | def solve():
import sys
file_input = sys.stdin
def marked_ancestor(v):
if v == ancestor[v]:
return v
else:
ancestor[v] = marked_ancestor(parent[v])
return ancestor[v]
def line_ans(line):
v = int(line[2:])
if line[0] == 'M':
... |
s227298360 | p01295 | u615353970 | 1420714231 | Python | Python | py | Runtime Error | 0 | 0 | 351 | # -*- coding: utf-8 -*-
import sys
import math
while True:
# a,b = map(int,raw_input().split(' '))
a = int(raw_input())
b = int(raw_input())
if (a == 0 and b == 0):
sys.exit()
res = ""
for i in range(a,a+b):
res += str(i);
ans = ""
for i in range(a,a+b):
ans+=res[... |
s740879705 | p01295 | u615353970 | 1420767582 | Python | Python | py | Runtime Error | 0 | 0 | 321 | # -*- coding: utf-8 -*-
import sys
import math
while True:
a,b = map(int,raw_input().split(' '))
if (a == 0 and b == 0):
sys.exit()
res = ""
for i in range(a,min(a+b,100/len(str(a)))):
res += str(i);
ans = ""
for i in range(a,a+b):
ans+=res[i-a]
print ans
... |
s663511304 | p01296 | u509278866 | 1531051555 | Python | Python3 | py | Runtime Error | 0 | 0 | 2862 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... |
s343941255 | p01296 | u509278866 | 1531280586 | Python | Python3 | py | Runtime Error | 0 | 0 | 2832 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... |
s640568490 | p01298 | u947762778 | 1509275494 | Python | Python3 | py | Runtime Error | 0 | 0 | 956 | import
def check(h, slist, l):
last = l
t = 0
for s in slist:
last += (s[0] - t) * h
last = min(last, l)
last -= (s[1] - s[0]) * (s[2]-h)
t = s[1]
if last < 0:
return False
last = min(last, l)
d1last = last
t -= 86400
for s in slist:... |
s627931259 | p01300 | u798803522 | 1471594019 | Python | Python3 | py | Runtime Error | 40000 | 8744 | 565 | targ = input()
while True:
ans = 0
length = len(targ)
for o in range(length-1):
disp = [0 for n in range(length)]
for i in range(o+1,length):
if targ[o] == '0':
disp[i] = ans
elif i == length - 1:
disp[i] = int((int(targ[o] + targ[o+1:... |
s302135327 | p01300 | u467175809 | 1529581102 | Python | Python | py | Runtime Error | 0 | 0 | 447 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
sys.setrecursionlimit(1000000)
while True:
S = reversed(raw_input())
if S == '0':
break
m = [1] + [0 for i in range(10)]
diff = ans = 0
even = 1
for c in S:
num = int(c)
diff += num *... |
s618666116 | p01300 | u467175809 | 1529582315 | Python | Python | py | Runtime Error | 0 | 0 | 218 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
sys.setrecursionlimit(1000000)
def fact(num):
if num <= 1:
return 1
return fact(num - 1) + 1
print fact(200000)
|
s731195987 | p01300 | u633068244 | 1398661062 | Python | Python | py | Runtime Error | 39860 | 9376 | 188 | while 1:
n = raw_input()
if n == "0": break
c = 0
for i in range(2,len(n) + 1):
for sp in range(len(n) - i + 1):
if n[sp] != "0" and int(n[sp:sp + i])%11 == 0:
c += 1
print c |
s891105972 | p01300 | u633068244 | 1398661625 | Python | Python | py | Runtime Error | 39860 | 9356 | 295 | def isEle(n):
s = 0
for i in range(len(n)):
s += (-1)**i * int(n[i])
return True if s%11 == 0 else False
while 1:
n = raw_input()
if n == "0": break
c = 0
for i in range(2,len(n) + 1):
for sp in range(len(n) - i + 1):
if n[sp] != "0" and isEle(n[sp:sp + i]):
c += 1
print c |
s182667109 | p01300 | u633068244 | 1398662613 | Python | Python | py | Runtime Error | 39860 | 10604 | 325 | while 1:
n = raw_input()
if n == "0": break
size = len(n)
s = 0
diff = [0]*(size + 1)
for i in range(size):
s += (-1)**i * int(n[i])
diff[i + 1] = s
c = 0
for sp in range(size - 1):
if n[sp] == "0":
continue
for l in range(2,size - sp + 1):
if abs((diff[sp + l] - diff[sp])%11) == 0:
c += 1
pr... |
s685935034 | p01300 | u633068244 | 1398662696 | Python | Python | py | Runtime Error | 39860 | 10620 | 363 | while 1:
try:
n = raw_input()
if n == "0": break
size = len(n)
s = 0
diff = [0]*(size + 1)
for i in range(size):
s += (-1)**i * int(n[i])
diff[i + 1] = s
c = 0
for sp in range(size - 1):
if n[sp] == "0":
continue
for l in range(2,size - sp + 1):
if abs((diff[sp + l] - diff[sp])%11) ... |
s865217099 | p01304 | u798803522 | 1470328641 | Python | Python3 | py | Runtime Error | 0 | 0 | 1495 | trial = int(input())
for t in range(trial):
targ = [int(n) for n in f.readline().split(' ')]
root = [[0 for n in range(targ[0] + 1)] for m in range(targ[1] + 1)]
matanum = int(f.readline())
for m in range(matanum):
matax,matay,secx,secy = (int(n) for n in f.readline().split(' '))
if mat... |
s097846838 | p01305 | u724548524 | 1528800621 | Python | Python3 | py | Runtime Error | 0 | 0 | 494 | import itertools
from decimal import Decimal, ROUND_HALF_UP
for _ in range(int(input())):
a, b = tuple(map(int, input().split())), tuple(map(int, input().split()))
c = 0
for i in itertools.permutations(b):
s = 0
for j in range(9):s += (a[j] + i[j]) * (a[j] > i[j])
if s > 85:c += 1
... |
s509432950 | p01306 | u724548524 | 1528858866 | Python | Python3 | py | Runtime Error | 0 | 0 | 836 | m = {"yotta":24, "zetta":21, "exa":18, "peta":15, "tera":12, "giga":9, "mega":6, "kilo":3, "hecto":2, "deca":1, "deci":-1, "centi":-2, "milli":-3, "micro":-6, "nano":-9, "pico":-12, "femto":-15, "ato":-18, "zepto":-21, "yocto":-24}
for _ in range(int(input())):
v, *b = input().split()
if len(b) == 2:
k,... |
s738681870 | p01308 | u352394527 | 1545418277 | Python | Python3 | py | Runtime Error | 0 | 0 | 790 | dic = {"C":0, "C#":1, "D":2, "D#":3,
"E":4, "F":5, "F#":6, "G":7,
"G#":8, "A":9, "A#":10, "B":11}
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
t_lst = [-100] + list(map(lambda x:dic[x],input().split()))
s_lst = list(map(lambda x:dic[x],input().split()))
s_lst.reverse()
... |
s274283675 | p01308 | u266872031 | 1435980102 | Python | Python | py | Runtime Error | 19920 | 8248 | 1295 |
def notetonum(notestr):
numlist=[]
nn=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"]
for c in notestr:
numlist.append(nn.index(c))
return numlist
Q=int(raw_input())
for q in range(Q):
[n,m]=[int(x) for x in raw_input().split()]
stairlist=notetonum(raw_input().split())
song... |
s578138117 | p01314 | u352394527 | 1531252104 | Python | Python3 | py | Runtime Error | 0 | 0 | 401 | #include <cstdio>
int main(void){
int n, i, j, cnt, tmp;
while(scanf("%d", &n)){
if(n == 0){
break;
}
cnt = 0;
for(i=1; i<n/2+1; i++){
for(j=i; j<n; j++){
tmp = (i + j) * (j - i + 1) / 2;
if(tmp == n){
cnt++;
break;
}
if(tmp > n){
... |
s666490564 | p01314 | u509775126 | 1529400222 | Python | Python3 | py | Runtime Error | 0 | 0 | 210 | while True:
n = int(input())
if n == 0:
break
c = 0
for i in range(2, 1001):
for a in range(1, 1001):
if i*a+(0.5*(i-1)*i) == n:
c += 1
print(c)
|
s449139744 | p01314 | u509775126 | 1529400832 | Python | Python3 | py | Runtime Error | 0 | 0 | 249 | while True:
try:
n = int(input())
except:
break
if n == 0:
break
c = 0
for i in range(2, 1001):
for a in range(1, 1001):
if i*a+(0.5*(i-1)*i) == n:
c += 1
print(c)
|
s914879601 | p01314 | u509775126 | 1529401353 | Python | Python3 | py | Runtime Error | 0 | 0 | 260 | while True:
try:
n = int(input())
except ValueError:
break
if n == 0:
break
c = 0
for i in range(2, 1001):
for a in range(1, 1001):
if i*a+(0.5*(i-1)*i) == n:
c += 1
print(c)
|
s731952836 | p01314 | u136916346 | 1529981572 | Python | Python3 | py | Runtime Error | 0 | 0 | 219 | while 1:
n=int(input())
if not n:break
t=0
cnt=0
for i in range(2,n+1):
o=n//i
t+=(i-1)
p=n-(i*o-t)
if o+p//i+1-i<1:break
if p%i==0:cnt+=1
print cnt
|
s965537061 | p01315 | u824193546 | 1503320935 | Python | Python3 | py | Runtime Error | 0 | 0 | 1024 | import numpy as np
import sys
def firster(former, latter):
com = [str(former), str(latter)]
com.sort()
#print(former)
#print(latter)
#print(com)
if com[0] == former:
return 1
return 0
def one_turn(N):
effs = [] #name
effs_val = {} #value
for i in range(N):
data = input().split()
period = 0
name = da... |
s898835776 | p01316 | u731235119 | 1423240200 | Python | Python | py | Runtime Error | 19930 | 5088 | 498 | while 1:
N, M = map(int,raw_input().split(" "))
if M == N == 0 :
break
y0 = 128
C = [int(raw_input()) for _ in range(M)]
x = [int(raw_input()) for _ in range(N)]
dp = {y0:0}
for i in range(N):
tmpdp = dict()
for k,v in dp.iteritems():
for c in C:
if k + c > 255:
y = 255
elif k + c < 0:
... |
s138518044 | p01316 | u731235119 | 1423289494 | Python | Python | py | Runtime Error | 19920 | 95072 | 554 | INF = float("inf")
while 1:
N, M = map(int,raw_input().split(" "))
if M == N == 0 :
break
y0 = 128
C = [int(raw_input()) for _ in range(M)]
x = [int(raw_input()) for _ in range(N)]
dp = [[INF for _ in range(256)] for _ in range(N+1)]
dp[0][128] = 0
for i in range(N):
for k in range(256):
v = dp[i][k]
... |
s455659395 | p01316 | u509278866 | 1528443190 | Python | Python3 | py | Runtime Error | 0 | 0 | 1207 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF... |
s294437711 | p01316 | u855199458 | 1530192706 | Python | Python3 | py | Runtime Error | 0 | 0 | 698 | # -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
def main():
N, M = inpl()
INF = 10**9
while N:
C = [int(input()) for _ in range(M)]
X = [int(input()) for _ in range(N)]
Y = [[INF]*256 for i in range(N+1)]
for i in range(256):
Y[0][... |
s358240800 | p01316 | u779627195 | 1354704947 | Python | Python | py | Runtime Error | 19930 | 73220 | 1066 | import sys
R = lambda:map(int,raw_input().split())
yNum = 256
MAX_VAL = 10**6
while 1:
n,m = R()
if not (n or m): break
c = []
x = [128]
for i in xrange(m):
c.append(int(raw_input()))
for i in xrange(n):
x.append(int(raw_input()))
## sub = [[0 for j in xrange(yNum)] for i in x... |
s603762297 | p01317 | u266872031 | 1428164242 | Python | Python | py | Runtime Error | 19920 | 6720 | 2374 | while(1):
[N,M]=[int(x) for x in raw_input().split()]
if N==0:
break
else:
landr=[[99999999 for x in range(N+1)] for y in range(N+1)]
sear=[[99999999 for x in range(N+1)] for y in range(N+1)]
islandname1=[i for i in range(N+1)] #ex.[0,0,2,3,3]
islandname2=[[i] for i i... |
s262743167 | p01317 | u266872031 | 1428168679 | Python | Python | py | Runtime Error | 19920 | 6732 | 2473 | while(1):
[N,M]=[int(x) for x in raw_input().split()]
if N==0:
break
else:
landr=[[99999999 for x in range(N+1)] for y in range(N+1)]
sear=[[99999999 for x in range(N+1)] for y in range(N+1)]
islandname1=[i for i in range(N+1)] #ex.[0,0,2,3,3]
islandname2=[[i] for i i... |
s080762166 | p01317 | u469154576 | 1501691224 | Python | Python3 | py | Runtime Error | 40000 | 10776 | 1717 | from queue import PriorityQueue
inf = 10**9
while True:
n, m = map(int, input().split())
if n == 0:
break
edgel = [[] for i in range(n)]
edges = [[] for i in range(n)]
for i in range(m):
x, y, t, sl = input().split()
x = int(x) - 1
y = int(y) - 1
t = int(t)
... |
s893255020 | p01317 | u469154576 | 1502476883 | Python | Python3 | py | Runtime Error | 0 | 0 | 2088 | inf = 10**9
dp = [[inf] * 200 for i in range(200)]
ldist = [[inf] * 200 for i in range(200)]
sdist = [[inf] * 200 for i in range(200)]
while True:
n, m = map(int, input().split())
if n == 0:
break
for i in range(n):
for j in range(n):
if i == j:
ldist[i][j] = sdis... |
s542728166 | p01317 | u469154576 | 1502477069 | Python | Python3 | py | Runtime Error | 0 | 0 | 2052 | inf = 10**9
dp = [[inf] * 200 for i in range(200)]
ldist = [[inf] * 200 for i in range(200)]
sdist = [[inf] * 200 for i in range(200)]
while True:
n, m = map(int, input().split())
if n == 0:
break
for i in range(n):
for j in range(n):
if i == j:
ldist[i][j] = sdis... |
s892620062 | p01317 | u469154576 | 1502477226 | Python | Python3 | py | Runtime Error | 0 | 0 | 2088 | inf = 10**9
dp = [[inf] * 210 for i in range(210)]
ldist = [[inf] * 210 for i in range(210)]
sdist = [[inf] * 210 for i in range(210)]
while True:
n, m = map(int, input().split())
if n == 0:
break
for i in range(n):
for j in range(n):
if i == j:
ldist[i][j] = sdis... |
s937344939 | p01317 | u469154576 | 1502502653 | Python | Python3 | py | Runtime Error | 40000 | 10720 | 2088 | inf = 10**9
dp = [[inf] * 210 for i in range(210)]
ldist = [[inf] * 210 for i in range(210)]
sdist = [[inf] * 210 for i in range(210)]
while True:
n, m = map(int, input().split())
if n == 0:
break
for i in range(n):
for j in range(n):
if i == j:
ldist[i][j] = sdis... |
s738947288 | p01317 | u469154576 | 1502506490 | Python | Python3 | py | Runtime Error | 40000 | 10780 | 1641 | inf = 10**9
dp = [[inf] * 210 for i in range(210)]
ldist = [[inf] * 210 for i in range(210)]
sdist = [[inf] * 210 for i in range(210)]
while True:
n, m = map(int, input().split())
if n == 0:
break
for i in range(n):
for j in range(n):
if i == j:
ldist[i][j] = sdist[i][j] = 0
else:
ldist[i][j] = sdi... |
s245785168 | p01317 | u266872031 | 1530190602 | Python | Python3 | py | Runtime Error | 0 | 0 | 1318 | # -*- coding: utf-8 -*-
def wf(A,N):
for k in range(1,N+1):
for i in range(1,N+1):
for j in range(1,N+1):
if A[i][j] > A[i][k]+A[k][j]:
A[i][j] = A[i][k]+A[k][j]
if __name__=="__main__":
while(1):
N,M=map(int, input().split())
... |
s956023974 | p01321 | u647766105 | 1389864672 | Python | Python | py | Runtime Error | 0 | 0 | 1728 | def toBinary(block):
return [sum(1 << i for i,bb in enumerate(b) if bb == "#") for b in block]
def toStr(bfield):
return ["".join("." if f & (1<<i) == 0 else "#" for i in xrange(W)) for f in bfield]
def rotated(block):
return map(lambda x:"".join(x),zip(*[b[:] for b in block]))[::-1]
def striped(block):
... |
s917393934 | p01322 | u078042885 | 1486866335 | Python | Python3 | py | Runtime Error | 0 | 0 | 169 | while 1:
n,a,b=map(int,input().split())
if n==a==b==0:break
c=0;d=[1]*(n+1)
for x in range(a):
for i in range(x*b,n+1,a):d[i]=0
print(sum(d)) |
s328825772 | p01325 | u724548524 | 1528854456 | Python | Python3 | py | Runtime Error | 0 | 0 | 750 | while 1:
n = int(input())
if n == 0:break
an, bn = n, n
a, b = list(map(int, input().split())), list(map(int, input().split()))
while 1:
ad = []
for i in range(an):
if a[i] == bn:
ad.append(i)
for j in range(bn):b[j] -= 1
elif a... |
s911288431 | p01325 | u724548524 | 1528856554 | Python | Python3 | py | Runtime Error | 0 | 0 | 789 | import bisect
while 1:
n = int(input())
if n == 0:break
a0, b0 = 0, 0
an, bn = n, n
p = (0, n, 0, n)
f = 1
a, b = list(sorted(map(int, input().split()))), list(sorted(map(int, input().split())))
if sum(a) != sum(b):print("No")
else:
while 1:
a0 = bisect.bisect_rig... |
s680164507 | p01329 | u352394527 | 1546025214 | Python | Python3 | py | Runtime Error | 0 | 0 | 2255 | from heapq import heappush, heappop
from collections import deque
def main():
while True:
n, m = map(int, input().split())
if n == 0:break
mp = ["#" * (m + 2)] + ["#" + input() + "#" for _ in range(n)] + ["#" * (m + 2)]
for y in range(1, n + 1):
for x in range(1, m + 1):
if mp[y][x] == ... |
s010445846 | p01333 | u099826363 | 1529581211 | Python | Python3 | py | Runtime Error | 0 | 0 | 322 | A,B = input().split()
A = int(A)
B = int(B)
if A == 0:
return
oturi = B - A
B1 = 0
C5 = 0
C1 = 0
if oturi/1000 >= 1:
B1+= int(oturi/1000)
oturi = oturi-(B1*1000)
if oturi % 500 == 0:
oturi = int(oturi)
while oturi >= 500:
oturi-=500
C5+=1
while oturi > 0:
oturi-=100
C1+=1
print(C1,C5,B1... |
s448210387 | p01333 | u099826363 | 1529581231 | Python | Python3 | py | Runtime Error | 0 | 0 | 322 | A,B = input().split()
A = int(A)
B = int(B)
if A == 0:
return
oturi = B - A
B1 = 0
C5 = 0
C1 = 0
if oturi/1000 >= 1:
B1+= int(oturi/1000)
oturi = oturi-(B1*1000)
if oturi % 500 == 0:
oturi = int(oturi)
while oturi >= 500:
oturi-=500
C5+=1
while oturi > 0:
oturi-=100
C1+=1
print(C1,C5,B1... |
s585293474 | p01333 | u099826363 | 1529581244 | Python | Python3 | py | Runtime Error | 0 | 0 | 324 | A,B = input().split()
A = int(A)
B = int(B)
if A == 0:
return 0
oturi = B - A
B1 = 0
C5 = 0
C1 = 0
if oturi/1000 >= 1:
B1+= int(oturi/1000)
oturi = oturi-(B1*1000)
if oturi % 500 == 0:
oturi = int(oturi)
while oturi >= 500:
oturi-=500
C5+=1
while oturi > 0:
oturi-=100
C1+=1
print(C1,C5,... |
s946735865 | p01336 | u266872031 | 1528596738 | Python | Python | py | Runtime Error | 0 | 0 | 991 | while(1):
try:
N,M=map( int,raw_input().split())
W=[[] for i in range(3)]
for i in range(N):
name=raw_input()
inp=map( int,raw_input().split())
c=inp[0]
for i in range(3):
W[i].append([c, inp[1+i]])
ans=0
for i ... |
s867736311 | p01336 | u266872031 | 1528597405 | Python | Python | py | Runtime Error | 0 | 0 | 1061 | while(1):
try:
N,M=map( int,raw_input().split())
W=[[] for i in range(3)]
for i in range(N):
name=raw_input()
inp=map( int,raw_input().split())
c=inp[0]
for i in range(3):
W[i].append([c, inp[1+i]])
for i in range(3):
... |
s306346574 | p01337 | u506537276 | 1559541255 | Python | Python3 | py | Runtime Error | 0 | 0 | 815 | import math
w1 = 1
w2 = 1/2 * (-1 + math.sqrt(3)*1j)
w3 = 1/2 * (-1 - math.sqrt(3)*1j)
n = int(input())
for i in range(n):
aa, bb, cc, dd = map(int, input().split())
a = bb / aa
b = cc / aa
c = dd / aa
p = -1/54 * (27 * c + 2 * (a ** 3) - 9 * a * b)
q = 1/9 * (3 * b - a ** 2)
r = 1/3 * a
x1 = w1 * ... |
s028153929 | p01337 | u506537276 | 1559541446 | Python | Python3 | py | Runtime Error | 0 | 0 | 815 | import math
w1 = 1
w2 = 1/2 * (-1 + math.sqrt(3)*1j)
w3 = 1/2 * (-1 - math.sqrt(3)*1j)
n = int(input())
for i in range(n):
aa, bb, cc, dd = map(int, input().split())
a = bb / aa
b = cc / aa
c = dd / aa
p = -1/54 * (27 * c + 2 * (a ** 3) - 9 * a * b)
q = 1/9 * (3 * b - a ** 2)
r = 1/3 * a
x1 = w1 * ... |
s025118805 | p01339 | u572790226 | 1466496141 | Python | Python3 | py | Runtime Error | 0 | 0 | 433 | def combi(n):
if n == 1:
return [[1],[0]]
else:
s = combi(n-1)
ret = [[t] + x for x in s for t in [1, 0]]
return ret
N, M = map(int, input().split())
whole = combi(N)
for i in range(M):
select = []
s, d = map(int, input().split())
for c in whole:
if c[s-1] ... |
s246584653 | p01359 | u010611609 | 1558954675 | Python | Python3 | py | Runtime Error | 0 | 0 | 488 | from bisect import bisect_left
while True:
N, Q = map(int, input().split(' '))
if N == 0:
break
era = {} # Like {1877: ('Meiji', 10)}
years = [] # 西暦
for _ in range(N):
name, j, w = input().split(' ')
j, w = int(j), int(w)
era[w] = (name, j)
years.append(w)
years.sort()
for _ in range(Q):
q = in... |
s002735211 | p01359 | u010611609 | 1558954686 | Python | Python3 | py | Runtime Error | 0 | 0 | 488 | from bisect import bisect_left
while True:
N, Q = map(int, input().split(' '))
if N == 0:
break
era = {} # Like {1877: ('Meiji', 10)}
years = [] # 西暦
for _ in range(N):
name, j, w = input().split(' ')
j, w = int(j), int(w)
era[w] = (name, j)
years.append(w)
years.sort()
for _ in range(Q):
q = in... |
s160327754 | p01359 | u010611609 | 1558954717 | Python | Python3 | py | Runtime Error | 0 | 0 | 488 | from bisect import bisect_left
while True:
N, Q = map(int, input().split(' '))
if N == 0:
break
era = {} # Like {1877: ('Meiji', 10)}
years = [] # 西暦
for _ in range(N):
name, j, w = input().split(' ')
j, w = int(j), int(w)
era[w] = (name, j)
years.append(w)
years.sort()
for _ in range(Q):
q = in... |
s548488560 | p01359 | u633068244 | 1398929316 | Python | Python | py | Runtime Error | 0 | 0 | 365 | while 1:
n,m = map(int,raw_input().split())
if n == 0: break
E,B,Y = [],[],[]
for i in range(n):
era,base,year = raw_input().split()
E.append(era)
B.append(int(base))
Y.append(int(year))
for i in range(m):
year = int(raw_input())
for j in range(n):
if Y[j]-B[j] < year <= Y[j]:
print E[i], year-Y... |
s095476133 | p01359 | u633068244 | 1398929360 | Python | Python | py | Runtime Error | 0 | 0 | 365 | while 1:
n,m = map(int,raw_input().split())
if n == 0: break
E,B,Y = [],[],[]
for i in range(n):
era,base,year = raw_input().split()
E.append(era)
B.append(int(base))
Y.append(int(year))
for i in range(m):
year = int(raw_input())
for j in range(n):
if Y[j]-B[j] < year <= Y[j]:
print E[i], year-Y... |
s494068016 | p01360 | u509278866 | 1528687171 | Python | Python3 | py | Runtime Error | 0 | 0 | 1695 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdi... |
s229146165 | p01369 | u352394527 | 1531260054 | Python | Python3 | py | Runtime Error | 0 | 0 | 545 | #include <iostream>
using namespace std;
int main(void){
string s, left;
int pos, tmp, cnt, i;
left = "qwertasdfgzxcvb";
while(1){
cin >> s;
if(s == "#"){
break;
}
if(left.find(s[0]) != std::string::npos){
pos = 0;
}else{
pos = 1;
}
cnt = 0;
for(i=1;i<s.length(... |
s427617304 | p01369 | u910106747 | 1497695535 | Python | Python | py | Runtime Error | 0 | 0 | 459 |
def solve(s):
dic = {}
ll = 'qwertasdfgzxcvb'
rr = 'yuiophjklnm'
for l_i in list(ll):
dic[l_i] = -1
for r_i in list(rr):
dic[r_i] = 1
ans = 0
prev = 0
for s_i in s:
current = dic[s_i]
if current != prev:
if abs(current - prev) == 2:
... |
s112054116 | p01369 | u412356196 | 1505819596 | Python | Python | py | Runtime Error | 0 | 0 | 869 | using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
HashSet<char> s = new HashSet<char> { };
string yukio = "yuiophjklnm";
for (int i = 0; i < yukio.Length; i++)
{
s.Add(yukio[i]);
}
while (true)
{
... |
s108190563 | p01370 | u633068244 | 1422281817 | Python | Python | py | Runtime Error | 19920 | 4604 | 599 | while 1:
t,n = map(int,raw_input().split())
if t == n == 0: break
block = [map(int,raw_input().split()) for _ in range(n)]
sx,sy = map(int,raw_input().split())
visited = []
visited.append([sx,sy])
que = [[sx,sy,t]]
ans = 1
while que:
x,y,tt = que.pop(0)
if tt == 0: co... |
s839353510 | p01370 | u617183767 | 1424151118 | Python | Python | py | Runtime Error | 19930 | 75532 | 1174 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import itertools
import math
from collections import Counter, defaultdict
class Main(object):
def __init__(self):
pass
def solve(self):
'''
insert your code
'''
while True:
t, n = map(... |
s726726705 | p01370 | u316268279 | 1426010217 | Python | Python3 | py | Runtime Error | 0 | 0 | 920 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import heapq as hq
def bfs(x,y,t,Map,depth):
queue = [(depth,(x,y))]
while len(queue) != 0:
p = hq.heappop(queue)
x,y = p[1]
if p[0] < t and Map[y][x] == 0:
Map[y][x] = 1
dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1... |
s590621074 | p01370 | u316268279 | 1426010327 | Python | Python3 | py | Runtime Error | 0 | 0 | 894 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import heapq as hq
def bfs(x,y,t,Map,depth):
queue = [(depth,(x,y))]
while len(queue) != 0:
p = hq.heappop(queue)
x,y = p[1]
if p[0] < t and Map[y][x] == 0:
Map[y][x] = 1
dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1... |
s771206258 | p01370 | u120360464 | 1434962263 | Python | Python | py | Runtime Error | 0 | 0 | 829 | #! /usr/bin/python
# -*- coding: utf-8 -*-
(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
M = [[False]*100 for i in range(100)]
for i in range(n):
(obx, oby) = map(int, raw_input().split())
M[oby+50][obx+50] = True
(sx, sy) = map(int, raw_input().split())
ST = [] #0:y 1:... |
s286229144 | p01370 | u120360464 | 1434962300 | Python | Python | py | Runtime Error | 0 | 0 | 829 | #! /usr/bin/python
# -*- coding: utf-8 -*-
(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
M = [[False]*100 for i in range(100)]
for i in range(n):
(obx, oby) = map(int, raw_input().split())
M[oby+50][obx+50] = True
(sx, sy) = map(int, raw_input().split())
ST = [] #0:y 1:... |
s036616488 | p01370 | u120360464 | 1434962430 | Python | Python | py | Runtime Error | 0 | 0 | 856 | #! /usr/bin/python
# -*- coding: utf-8 -*-
(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
M = [[False]*100 for i in range(100)]
for i in range(n):
(obx, oby) = map(int, raw_input().split())
M[oby+50][obx+50] = True
(sx, sy) = map(int, raw_input().split())
ST = [] #0:y 1:... |
s681857036 | p01371 | u731235119 | 1423155828 | Python | Python | py | Runtime Error | 19920 | 15600 | 694 | while 1:
N = int(raw_input())
if N == 0: break
stage = set(range(1,N+1))
time = [None] + [map(int,raw_input().split(" ")) for _ in range(N)]
dp = dict([[tuple([i]),time[i][0]] for i in range(1,N+1)])
count = 1
while count < N:
tmp_dp = dict()
for k, v in dp.iteritems():
cleared = set(k)
for st in stage... |
s129883039 | p01371 | u731235119 | 1423196071 | Python | Python | py | Runtime Error | 19930 | 9340 | 515 | INF = float("inf")
while 1:
N = int(raw_input())
if N == 0: break
time = [map(int,raw_input().split(" ")) for _ in range(N)]
dp = [INF for i in range(2**N)]
dp[0] = 0
for cleared in range(2**N):
for i in range(0,N):
now = 2 ** i
if now & cleared != 0:
continue
tmp_time = time[i][0]
for j in rang... |
s132813653 | p01371 | u633068244 | 1424356118 | Python | Python | py | Runtime Error | 0 | 0 | 964 | #include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#define REP(i,a,b) for (int i = (a); i < (b); i++)
#define rep(i,a) REP(i,0,a)
using namespace std;
const int INF = 1 << 28;
int sp, N;
int t[16][17];
int dp[1 << 16][16];
int rec(int S, int v) {
if (dp[S][v] > 0) return dp[S][v];
... |
s340427608 | p01371 | u981364540 | 1471355446 | Python | Python3 | py | Runtime Error | 40000 | 10748 | 507 | import sys
while 1:
N = int(input())
if N == 0 : break
t = [list(map(int, input().split())) for i in range(N)]
dp = [sys.maxsize]*(1<<N)
dp[0] = 0
for i in range(1<<N):
for j in range(N):
if (i & (1<<j)) != 0: continue
cost = t[j][0]
for k in range(N):... |
s311897101 | p01371 | u981364540 | 1471355873 | Python | Python3 | py | Runtime Error | 40000 | 10692 | 507 | import sys
while 1:
N = int(input())
if N == 0 : break
t = [list(map(int, input().split())) for i in range(N)]
dp = [sys.maxsize]*(1<<N)
dp[0] = 0
for i in range(1<<N):
for j in range(N):
if (i & (1<<j)) != 0: continue
cost = t[j][0]
for k in range(N):... |
s942287952 | p01371 | u981364540 | 1471356327 | Python | Python3 | py | Runtime Error | 40000 | 10860 | 512 | import sys
while 1:
N = int(input())
if N == 0 : sys.exit()
t = [list(map(int, input().split())) for i in range(N)]
dp = [sys.maxsize]*(1<<N)
dp[0] = 0
for i in range(1<<N):
for j in range(N):
if (i & (1<<j)) != 0: continue
cost = t[j][0]
for k in rang... |
s455211174 | p01371 | u981364540 | 1471356440 | Python | Python3 | py | Runtime Error | 40000 | 10696 | 507 | import sys
while 1:
N = int(input())
if N == 0 : sys.exit()
t = [list(map(int, input().split())) for i in range(N)]
dp = [500000]*(1<<N)
dp[0] = 0
for i in range(1<<N):
for j in range(N):
if (i & (1<<j)) != 0: continue
cost = t[j][0]
for k in range(N):... |
s159442751 | p01371 | u981364540 | 1471356979 | Python | Python3 | py | Runtime Error | 40000 | 10700 | 515 | import sys
while True:
N = int(input())
if N == 0 : sys.exit()
t = [list(map(int, input().split())) for i in range(N)]
dp = [sys.maxsize]*(1<<N)
dp[0] = 0
for i in range(1<<N):
for j in range(N):
if (i & (1<<j)) != 0: continue
cost = t[j][0]
for k in r... |
s687571056 | p01371 | u685815919 | 1474616666 | Python | Python | py | Runtime Error | 40000 | 8488 | 727 | import sys
def bitdp(N, costs):
dp = [sys.maxint] * 2**N
dp[0] = 0
# min cost of state i is calcurated by minimum of
# before state i-2**k + cost of minimum for clear k
for i in xrange(1, 2 ** N):
for k in xrange(N):
if i & 2**k > 0:
mincost = costs[k][0]
for x in xrange(0, N):
... |
s647109603 | p01371 | u672443148 | 1515145101 | Python | Python3 | py | Runtime Error | 0 | 0 | 912 | while True:
N=int(input())
if N==0:
break
stage=[]
for i in range(N):
stage.append(list(map(int,input().split())))
INF=int(1e8)
dp=[INF for i in range(1<<N)]
dp[0]=0
for bit in range(1<<N): #ステージのクリア状況分だけループを回す
for i in range(N):
if bit & 1<... |
s503495011 | p01371 | u855199458 | 1530101847 | Python | Python3 | py | Runtime Error | 0 | 0 | 777 | # -*- coding: utf-8 -*-
from itertools import combinations
N = int(input())
while N:
T = []
B = []
for i in range(N):
base, *other = list(map(int, input().split()))
B.append(base)
T.append(other)
cost = [10**7]*(2**N)
X = [2**i for i in range(N)]
for i, x in enumerate(X)... |
s081314435 | p01371 | u352394527 | 1530574783 | Python | Python3 | py | Runtime Error | 0 | 0 | 695 | INF = 10 ** 20
def minimum_cost(now, visited):
if (now, visited) in dp:
return dp[(now, visited)]
if visited == end:
return 0
ret = INF
for to in range(1, n + 1):
if to not in visited:
ret = min(ret, minimum_cost(to, tuple(sorted(list(visited) + [to]))) + cost(to, visited))
dp[(now, visi... |
s748093039 | p01371 | u352394527 | 1530580014 | Python | Python3 | py | Runtime Error | 0 | 0 | 769 | INF = 10 ** 20
def minimum_cost(rest, dp, tlst, end, n):
if rest in dp:
return dp[rest]
if rest == end:
return 0
ret = INF
for ind, to in enumerate(rest):
if to == "0":
tmp = minimum_cost(rest[:ind] + "1" + rest[ind + 1:], dp, tlst, end, n) + cost(ind, rest, tlst, n)
if tmp < ret:
... |
s685313398 | p01371 | u109084363 | 1361955394 | Python | Python | py | Runtime Error | 19930 | 4616 | 718 | import sys
import collections
while True:
N = int(raw_input())
if N == 0:
break
time = []
for i in xrange(N):
time.append(map(int, raw_input().split()))
def dp(state):
L = len(state)
if L <= 1:
return time[state[0]][0]
else:
temp ... |
s960730773 | p01371 | u109084363 | 1361955533 | Python | Python | py | Runtime Error | 19930 | 4252 | 516 | import sys
while True:
N = int(raw_input())
if N == 0:
break
time = []
for i in xrange(N):
time.append(map(int, raw_input().split()))
def dp(state):
L = len(state)
if L <= 1:
return time[state[0]][0]
else:
temp = []
for i in state:
copy = state[:]
copy.remove(i)
min_time = time[i]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.