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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s691181321 | p00491 | u587821863 | 1416489370 | Python | Python3 | py | Runtime Error | 0 | 0 | 916 | #f = open("input.txt")
#N, K = [int(x) for x in f.readline().split(' ')]
#lines = f.readlines()
import sys
N, K = [int(x) for x in sys.stdin.readline().split(' ')]
lines = sys.stdin.readlines()
f.close()
schedule = [0]*N
for line in lines:
strs = line.split(' ')
schedule[int(strs[0])-1] = int(strs[1])
number = [0]*9
for i in range(9):
l1 = i // 3
l2 = i % 3
if(schedule[0]!=l1+1 and schedule[0]!=0):
number[i] = 0
elif(schedule[1]!=l2+1 and schedule[1]!=0):
number[i] = 0
else:
number[i] = 1
for s in schedule[2:]:
new_number = [0]*9
for i in range(9):
l1 = i // 3
l2 = i % 3
for j in range(3):
new_number[i] += number[l2*3 + j] if((s==0 or s==l1+1) and not (l2==j and l1==j)) else 0
for i in range(9):
number[i] = new_number[i] % 10000
sum = 0
for n in number:
sum += n
print(sum % 10000) |
s566400070 | p00491 | u811434779 | 1441372861 | Python | Python | py | Runtime Error | 40000 | 6408 | 491 | n, k = map(int, raw_input().split())
d = {}
for i in range(k):
a, b = map(int, raw_input().split())
d[a] = b
dp =[[[[0]*(n+1) for i in range(4)] for j in range(4)] for k in range(4)]
def solve(a, b, c, i):
if a == b == c: return 0
if i in d and d[i] != c: return 0
if i == n: return 1
dp[a][b][c][i] = (solve(b,c,1,i+1) + solve(b,c,2,i+1) + solve(b,c,3,i+1)) % 10000
return dp[a][b][c][i]
ans = (solve(0,0,1,1) + solve(0,0,2,1) + solve(0,0,3,1)) % 10000
print ans |
s726058122 | p00491 | u150984829 | 1527638800 | Python | Python3 | py | Runtime Error | 20 | 5604 | 467 | N,K=map(int,input().split())
S=[0]*N
for _ in[0]*K:
a,b=map(int,input().split())
S[a-1]=b
dp=[0]*9
st,nd=S[:2]
if st:
if nd:dp[~-st*3+~-nd]=1
else:dp[~-st*3:st*3]=[1]*3
elif nd:dp[~-st::3]=[1]*3
else:dp=[1]*9
for i in range(2,N):
cur=S[i];tmp=[0]*9
if cur:
cur-=1
for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
else:
for cur in range(3):
for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
dp=tmp[:]
print(sum(dp)%10000)
|
s745630072 | p00492 | u621997536 | 1419685371 | Python | Python3 | py | Runtime Error | 30 | 6768 | 801 | W, H = map(int, input().split())
m = [list(map(int, input().split())) for i in range(H)]
dx = [[1, 1, 1, 0, -1, 0], [0, 1, 0, -1, -1, -1]]
dy = [-1, 0, 1, 1, 0, -1]
def dfs(x, y):
if m[y][x] != 0:
return
m[y][x] = 2
for xx, yy in zip(dx[y % 2], dy):
tx, ty = x + xx, y + yy
if 0 <= tx < W and 0 <= ty < H:
dfs(tx, ty)
for x in range(W):
dfs(x, 0)
dfs(x, H - 1)
for y in range(H):
dfs(0, y)
dfs(W - 1, y)
from itertools import product
n = 0
for x, y in product(range(W), range(H)):
if m[y][x] != 1:
continue
fn = n
for xx, yy in zip(dx[y % 2], dy):
tx, ty = x + xx, y + yy
if 0 <= tx < W and 0 <= ty < H:
if m[ty][tx] == 2:
n += 1
else:
n += 1
print(n) |
s203972415 | p00492 | u352394527 | 1526831225 | Python | Python3 | py | Runtime Error | 30 | 5620 | 1509 | WALL = 100
w, h = map(int,input().split())
lst = [[WALL] + list(map(int,input().split())) + [WALL] for i in range(h)]
lst.insert(0, [WALL] * (w + 2))
lst.append([WALL] * (w + 2))
visited = [[0] * (w + 2) for _ in range(h + 2)]
hold = []
def search(x, y):
if lst[x][y] == WALL:
visited[x][y] = 3
return 3
if lst[x][y] == 1:
visited[x][y] = 2
return 2
visited[x][y] = 1
hold.append((x, y))
if not x % 2:
pairs = [(x - 1, y - 1), (x - 1, y), (x, y - 1), (x, y + 1), (x + 1, y - 1), (x + 1, y)]
else:
pairs = [(x - 1, y), (x - 1, y + 1), (x, y - 1), (x, y + 1), (x + 1, y), (x + 1, y + 1)]
ret = 0
for t in pairs:
tx, ty = t[0], t[1]
a = 0
if not visited[tx][ty]:
a = search(tx, ty)
elif visited[x][y] == 3:
a = 3
elif visited[x][y] == 2:
a = 2
if a > ret:
ret = a
return ret
for x in range(1, h + 1):
for y in range(1, w + 1):
if not visited[x][y] and not lst[x][y]:
stat = search(x, y)
for point in hold:
visited[point[0]][point[1]] = stat
hold.clear()
ans = 0
for x in range(1, h + 1):
for y in range(1, w + 1):
if lst[x][y]:
if not x % 2:
pairs = [(x - 1, y - 1), (x - 1, y), (x, y - 1), (x, y + 1), (x + 1, y - 1), (x + 1, y)]
else:
pairs = [(x - 1, y), (x - 1, y + 1), (x, y - 1), (x, y + 1), (x + 1, y), (x + 1, y + 1)]
for t in pairs:
tx, ty = t[0], t[1]
if visited[tx][ty] in [0,3]:
ans += 1
print(ans)
|
s955277059 | p00493 | u235282710 | 1476626626 | Python | Python | py | Runtime Error | 40000 | 6540 | 517 | #!/usr/bin/env python
A = int(raw_input())
B = int(raw_input())
M = int(raw_input())
ans = 0
def is_zig_zag(d):
s = str(d)
if len(s) == 1: return True
if s[0] < s[1]:
b = True
elif s[0] > s[1]:
b = False
else:
return False
for i in xrange(1, len(s)):
if not b and s[i-1] <= s[i]: return False
if b and s[i-1] >= s[i]: return False
b = not b
return True
i = A
while i % M != 0:
i += 1
while i <= B:
if is_zig_zag(i):
ans = (ans + 1) % 10000
i += M
print ans |
s908988709 | p00494 | u489809100 | 1448359353 | Python | Python | py | Runtime Error | 40000 | 7544 | 281 | JOI = raw_input()
JJOOII = ["J", "O", "I"]
max = 0
now = 1
while len(JJOOII) <= len(JOI):
if "".join(JJOOII) in JOI : max = now
JJOOII.insert(JJOOII.index("J") + 1, "J")
JJOOII.insert(JJOOII.index("O") + 1, "O")
JJOOII.insert(JJOOII.index("I") + 1, "I")
now += 1
print max |
s229644468 | p00494 | u489809100 | 1448359679 | Python | Python | py | Runtime Error | 40000 | 7364 | 201 | JOI = raw_input()
JJOOII = "JOI"
max = 0
n = 1
while len(JJOOII) <= len(JOI):
if JJOOII in JOI : max = n
JJOOII = JJOOII[0:n] + "J" + JJOOII[n:n*2] + "O" + JJOOII[n*2:n*3] + "I"
n += 1
print max |
s994418514 | p00494 | u266872031 | 1521366885 | Python | Python | py | Runtime Error | 0 | 4660 | 318 | S=raw_input()+"n"
A=[]
M="JOI"
i=0
m=M[0]
c=S[0]
n=0
for s in S:
if c==s:
n+=1
else:
if c==m:
A.append(n)
i+=1
else:
A.append(0)
i=0
m=M[i%3]
c=s
n=1
ans= max([min(A[x:x+3]) for x in range(len(A)-2) ])
print ans
|
s424827939 | p00494 | u104911888 | 1368109019 | Python | Python | py | Runtime Error | 20000 | 19348 | 141 | S=raw_input()
N=len(S)
for k in range(N/3,0,-1):
s="J"*k+"O"*k+"I"*k
if S.count(s)>0:
print k
break
else:
print 0 |
s548457522 | p00494 | u572424947 | 1376558571 | Python | Python | py | Runtime Error | 10 | 4224 | 213 | import re
string = raw_input()
mutch = re.findall("J*O*I*", string)
max = 0
for s in mutch:
if s.count("O") == min([s.count(c) for c in ("J", "O", "I")]):
k = s.count("O")
if k > max:
max = k
print max |
s510346947 | p00494 | u572424947 | 1376558845 | Python | Python | py | Runtime Error | 10 | 4224 | 213 | import re
string = raw_input()
match = re.findall("J+O+I+", string)
max = 0
for s in match:
if s.count("O") == min([s.count(c) for c in ("J", "O", "I")]):
k = s.count("O")
if k > max:
max = k
print max |
s281808562 | p00494 | u572424947 | 1376558930 | Python | Python | py | Runtime Error | 20000 | 8248 | 220 | import re
string = raw_input()
match = re.findall("J+O+I+", string)
max = 0
for s in match:
k = 0
if s.count("O") == min([s.count(c) for c in ("J", "O", "I")]):
k = s.count("O")
if k > max:
max = k
print max |
s482497921 | p00494 | u547057305 | 1381076448 | Python | Python | py | Runtime Error | 20000 | 5296 | 305 | s = raw_input()
k = x = 0
while 1:
x += 1
if "J"*x+"O"*x+"I"*x in s:
k = x
elif "J"*x in s:
pass
elif "O"*x in s:
pass
elif "I"*x in s:
pass
else:
print(k)
break |
s317142529 | p00494 | u547057305 | 1381076789 | Python | Python | py | Runtime Error | 20000 | 5300 | 334 | s = raw_input()
k = x = 0
while 1:
x += 1
if "J"*x+"O"*x+"I"*x in s:
k = x
elif not "J"*x in s:
print(k)
break
elif not "O"*x in s:
print(k)
break
elif not "I"*x in s:
print(k)
break |
s131578647 | p00494 | u547057305 | 1381077512 | Python | Python | py | Runtime Error | 20000 | 5324 | 347 | s = raw_input()
k = x = 0
while x < len(s)*0.4:
x += 1
if "J"*x+"O"*x+"I"*x in s:
k = x
elif not "J"*x in s:
print(k)
break
elif not "O"*x in s:
print(k)
break
elif not "I"*x in s:
print(k)
break |
s474026355 | p00494 | u093607836 | 1390065939 | Python | Python | py | Runtime Error | 39860 | 17388 | 120 | s = raw_input()
for i in reversed(range(1,len(s)/3+1)):
if 'J' * i + 'O' * i + 'I' * i in s:
print i
exit()
print 0 |
s027559567 | p00494 | u633068244 | 1397473749 | Python | Python | py | Runtime Error | 39860 | 19228 | 115 | a=raw_input()
for k in range(len(a)//3,0,-1):
joi="J"*k+"O"*k+"I"*k
if joi in a:
print k
break
else:
print 0 |
s456599446 | p00494 | u633068244 | 1397473901 | Python | Python | py | Runtime Error | 39860 | 19212 | 155 | a=raw_input()
sp=min(a.count("J"),a.count("I"),a.count("O"))
for k in range(sp,0,-1):
joi="J"*k+"O"*k+"I"*k
if joi in a:
print k
break
else:
print 0 |
s396466644 | p00495 | u811434779 | 1443440948 | Python | Python | py | Runtime Error | 4770 | 6780 | 342 | a, b = map(int, raw_input().split())
p = map(int, raw_input().split())
q = map(int, raw_input().split())
ans = 0
for i in range(a):
if b - i <= ans: break
j = 0; k = i
cnt = 0
while 1:
if p[j] == q[k]:
cnt += 1; j += 1; k += 1
else: j += 1
if j == a: break
ans = max(ans, cnt)
print ans |
s583093234 | p00495 | u811434779 | 1443441756 | Python | Python | py | Runtime Error | 0 | 0 | 441 | l = map(int, raw_input().split())
if len(l) == 2:
a = l[0]; b = l[1]
else:
a = l[0]; b = input()
p = map(int, raw_input().split())
q = map(int, raw_input().split())
ans = 0
#?°??????????
for i in range(a):
if b - i <= ans or a - i <= ans: break
j = 0; k = i
cnt = 0
while 1:
if p[j] == q[k]:
cnt += 1; j += 1; k += 1
else: j += 1
if j == a: break
ans = max(ans, cnt)
print ans |
s432954913 | p00495 | u078042885 | 1485184682 | Python | Python3 | py | Runtime Error | 5160 | 8224 | 215 | c,d=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
p=i;q=0
for j in range(c):
if a[j]==b[p]:q+=1;p+=1
e=max(e,q)
i+=1
print(e) |
s383995171 | p00495 | u078042885 | 1485198334 | Python | Python3 | py | Runtime Error | 0 | 0 | 267 | s=map(int,input().split())
if len(s)==2:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
p=i;q=0
for j in range(c):
if a[j]==b[p]:q+=1;p+=1
e=max(e,q)
i+=1
print(e) |
s922854014 | p00495 | u078042885 | 1485207716 | Python | Python3 | py | Runtime Error | 0 | 0 | 237 | try:c,d=int(input().split())
except:d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
p=i;q=0
for j in range(c):
if a[j]==b[p]:q+=1;p+=1
e=max(e,q)
i+=1
print(e) |
s800005462 | p00495 | u078042885 | 1485207816 | Python | Python3 | py | Runtime Error | 5300 | 8184 | 241 | try:c,d=map(int,input().split())
except:d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
p=i;q=0
for j in range(c):
if a[j]==b[p]:q+=1;p+=1
e=max(e,q)
i+=1
print(e) |
s867638355 | p00495 | u078042885 | 1485238453 | Python | Python3 | py | Runtime Error | 5170 | 8092 | 243 | try:c,d=map(int,input().split())
except:c,d=5000;input()
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
p=i;q=0
for j in range(c):
if a[j]==b[p]:q+=1;p+=1
e=max(e,q)
i+=1
print(e) |
s463633224 | p00495 | u197615397 | 1508941526 | Python | Python3 | py | Runtime Error | 0 | 0 | 511 | def solve():
A, B = map(int, input().split())
s1 = tuple(map(int, input().split()))
s2 = tuple(map(int, input().split()))
result = 0
for i in range(B):
k = 0
cnt = 0
for j, n in enumerate(s2[i:]):
while k < A and n != s1[k]:
k += 1
if n == s1[k]:
cnt += 1
if k == A:
break
if cnt > result:
result = cnt
print(result)
if __name__ == "__main__":
solve() |
s274303308 | p00496 | u317901693 | 1415174351 | Python | Python | py | Runtime Error | 19930 | 92200 | 876 | # coding: utf-8
import sys
sys.setrecursionlimit(10000)
input_lines = []
input_lines.append(raw_input())
N,T,S = [int(x) for x in input_lines[0].split(' ')]
data = []
for i in range(N):
input_lines.append(raw_input())
a,b = [int(x) for x in input_lines[i+1].split(' ')]
data.append([a,b])
dp = [[0 for i in range(T+1)]for j in range(N+1)]
judge = 0
judge2 = 0
def rec(i,t):
global judge
global judge2
if judge2 == 1 and t < T-S:
judge =1
if dp[i][t] != 0:
return dp[i][t]
if i == N:
res = 0
elif t < data[i][1] or (judge == 0 and t - data[i][1] < T-S and data[i][1] > T-S):
res = rec(i+1,t)
else:
if judge == 0 and t - data[i][1] < T-S and data[i][1] <= T-S:
judge2 = 1
res = max(rec(i+1,t),rec(i+1,T-S-data[i][1])+data[i][0])
judge = 0
else:
res = max(rec(i+1,t),rec(i+1,t-data[i][1])+data[i][0])
dp[i][t] = res
return res
print rec(0,T) |
s864622899 | p00496 | u317901693 | 1415174547 | Python | Python | py | Runtime Error | 19930 | 92200 | 876 | # coding: utf-8
import sys
sys.setrecursionlimit(10000)
input_lines = []
input_lines.append(raw_input())
N,T,S = [int(x) for x in input_lines[0].split(' ')]
data = []
for i in range(N):
input_lines.append(raw_input())
a,b = [int(x) for x in input_lines[i+1].split(' ')]
data.append([a,b])
dp = [[0 for i in range(T+1)]for j in range(N+1)]
judge = 0
judge2 = 0
def rec(i,t):
global judge
global judge2
if judge2 == 1 and t < T-S:
judge =1
if dp[i][t] != 0:
return dp[i][t]
if i == N:
res = 0
elif t < data[i][1] or (judge == 0 and t - data[i][1] < T-S and data[i][1] > T-S):
res = rec(i+1,t)
else:
if judge == 0 and t - data[i][1] < T-S and data[i][1] <= T-S:
judge2 = 1
res = max(rec(i+1,t),rec(i+1,T-S-data[i][1])+data[i][0])
judge = 0
else:
res = max(rec(i+1,t),rec(i+1,t-data[i][1])+data[i][0])
dp[i][t] = res
return res
print rec(0,T) |
s392680110 | p00496 | u647766105 | 1391502277 | Python | Python | py | Runtime Error | 39860 | 76400 | 485 | N, T, S = map(int, raw_input().split())
L = [map(int, raw_input().split()) for _ in xrange(N)]
dp = [[0] * (T + 1) for _ in xrange(N)]
for n in xrange(N):
for t, c in L[:n + 1]:
for i in xrange(S - c - 1, -1, -1):
dp[n][i + c] = max(dp[n][i + c], dp[n][i] + t)
for n in xrange(N):
dp[n][S + 1] = max(dp[n])
for t, c in L[n + 1:]:
for i in xrange(T - c, S, -1):
dp[n][i + c] = max(dp[n][i + c], dp[n][i] + t)
print max(map(max, dp)) |
s472993350 | p00496 | u647766105 | 1391503267 | Python | Python | py | Runtime Error | 40 | 4320 | 344 | N, T, S = map(int, raw_input().split())
L = [map(int, raw_input().split()) for _ in xrange(N)]
dp = [0] * (T + 1)
for t, c in L:
for i in xrange(T - c, -1, -1):
if i > S or (i + c) < S:
dp[i + c] = max(dp[i + c], dp[i] + t)
ma = max(dp[:S])
for i in xrange(T, S, -1):
dp[i] = max(ma, dp[i])
print max(dp) |
s508558890 | p00499 | u814278309 | 1559481297 | Python | Python3 | py | Runtime Error | 0 | 0 | 287 | while True:
l=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a%c==0 and b%d==0:
if a/c>=b/d:
print(l-(a//c))
else:
print(l-(b//d))
else:
x=(a//c)+1
y=(b//d)+1
if x>=y:
print(l-x)
else:
print(l-y)
|
s366247740 | p00503 | u985367427 | 1414733611 | Python | Python3 | py | Runtime Error | 0 | 0 | 1388 | input_str = raw_input()
N, K = [int(x) for x in input_str[0].split(' ')]
x_grid = set()
y_grid = set()
d_grid = set()
for line in input_str[1:]:
x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
x_grid.add(x1)
x_grid.add(x2)
y_grid.add(y1)
y_grid.add(y2)
d_grid.add(d1)
d_grid.add(d2)
x_grid = sorted(x_grid)
y_grid = sorted(y_grid)
d_grid = sorted(d_grid)
x_grid_index = {x[1]:x[0] for x in enumerate(x_grid)}
y_grid_index = {y[1]:y[0] for y in enumerate(y_grid)}
d_grid_index = {d[1]:d[0] for d in enumerate(d_grid)}
fish_dist = np.zeros( (len(x_grid), len(y_grid), len(d_grid)), dtype=int )
for line in input_str[1:]:
x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
x1_index = x_grid_index[x1]
x2_index = x_grid_index[x2]
y1_index = y_grid_index[y1]
y2_index = y_grid_index[y2]
d1_index = d_grid_index[d1]
d2_index = d_grid_index[d2]
fish_dist[x1_index:x2_index, y1_index:y2_index, d1_index:d2_index] += 1
volume = 0
for (x_index, y_index, d_index), num in np.ndenumerate(fish_dist):
if num >= K:
x_begin = x_grid[x_index]
y_begin = y_grid[y_index]
d_begin = d_grid[d_index]
x_end = x_grid[x_index + 1]
y_end = y_grid[y_index + 1]
d_end = d_grid[d_index + 1]
volume += (x_end - x_begin) * (y_end - y_begin) * (d_end - d_begin)
print volume |
s179799236 | p00503 | u985367427 | 1414733687 | Python | Python | py | Runtime Error | 0 | 0 | 1388 | input_str = raw_input()
N, K = [int(x) for x in input_str[0].split(' ')]
x_grid = set()
y_grid = set()
d_grid = set()
for line in input_str[1:]:
x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
x_grid.add(x1)
x_grid.add(x2)
y_grid.add(y1)
y_grid.add(y2)
d_grid.add(d1)
d_grid.add(d2)
x_grid = sorted(x_grid)
y_grid = sorted(y_grid)
d_grid = sorted(d_grid)
x_grid_index = {x[1]:x[0] for x in enumerate(x_grid)}
y_grid_index = {y[1]:y[0] for y in enumerate(y_grid)}
d_grid_index = {d[1]:d[0] for d in enumerate(d_grid)}
fish_dist = np.zeros( (len(x_grid), len(y_grid), len(d_grid)), dtype=int )
for line in input_str[1:]:
x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
x1_index = x_grid_index[x1]
x2_index = x_grid_index[x2]
y1_index = y_grid_index[y1]
y2_index = y_grid_index[y2]
d1_index = d_grid_index[d1]
d2_index = d_grid_index[d2]
fish_dist[x1_index:x2_index, y1_index:y2_index, d1_index:d2_index] += 1
volume = 0
for (x_index, y_index, d_index), num in np.ndenumerate(fish_dist):
if num >= K:
x_begin = x_grid[x_index]
y_begin = y_grid[y_index]
d_begin = d_grid[d_index]
x_end = x_grid[x_index + 1]
y_end = y_grid[y_index + 1]
d_end = d_grid[d_index + 1]
volume += (x_end - x_begin) * (y_end - y_begin) * (d_end - d_begin)
print volume |
s836942353 | p00503 | u985367427 | 1414734620 | Python | Python3 | py | Runtime Error | 0 | 0 | 1498 | import numpy as np
input_str = raw_input()
N, K = [int(x) for x in input_str.split(' ')]
input_lines = []
for n in range(N):
input_str = raw_input()
input_lines.append(input_str)
x_grid = set()
y_grid = set()
d_grid = set()
for line in input_lines:
x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
x_grid.add(x1)
x_grid.add(x2)
y_grid.add(y1)
y_grid.add(y2)
d_grid.add(d1)
d_grid.add(d2)
x_grid = sorted(x_grid)
y_grid = sorted(y_grid)
d_grid = sorted(d_grid)
x_grid_index = {x[1]:x[0] for x in enumerate(x_grid)}
y_grid_index = {y[1]:y[0] for y in enumerate(y_grid)}
d_grid_index = {d[1]:d[0] for d in enumerate(d_grid)}
fish_dist = np.zeros( (len(x_grid), len(y_grid), len(d_grid)), dtype=int )
for line in input_lines:
x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
x1_index = x_grid_index[x1]
x2_index = x_grid_index[x2]
y1_index = y_grid_index[y1]
y2_index = y_grid_index[y2]
d1_index = d_grid_index[d1]
d2_index = d_grid_index[d2]
fish_dist[x1_index:x2_index, y1_index:y2_index, d1_index:d2_index] += 1
volume = 0
for (x_index, y_index, d_index), num in np.ndenumerate(fish_dist):
if num >= K:
x_begin = x_grid[x_index]
y_begin = y_grid[y_index]
d_begin = d_grid[d_index]
x_end = x_grid[x_index + 1]
y_end = y_grid[y_index + 1]
d_end = d_grid[d_index + 1]
volume += (x_end - x_begin) * (y_end - y_begin) * (d_end - d_begin)
print(volume) |
s076436822 | p00503 | u985367427 | 1414742586 | Python | Python3 | py | Runtime Error | 0 | 0 | 1839 | import sys
import array
input_lines = sys.stdin.read().splitlines()
N, K = [int(x) for x in input_lines[0].split(' ')]
x_grid = set()
y_grid = set()
d_grid = set()
for line in input_lines[1:]:
x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
x_grid.add(x1)
x_grid.add(x2)
y_grid.add(y1)
y_grid.add(y2)
d_grid.add(d1)
d_grid.add(d2)
x_grid = sorted(x_grid)
y_grid = sorted(y_grid)
d_grid = sorted(d_grid)
x_grid_index = {x[1]:x[0] for x in enumerate(x_grid)}
y_grid_index = {y[1]:y[0] for y in enumerate(y_grid)}
d_grid_index = {d[1]:d[0] for d in enumerate(d_grid)}
fish_dist = array.array('i', [0 for x in xrange(len(x_grid) * len(y_grid) * len(d_grid))])
def index2arr(x, y, d):
return x + len(x_grid) * y + len(x_grid) * len(y_grid) * d
def arr2index(index):
x = index % len(x_grid)
y = ((index - x) / len(x_grid)) % len(y_grid)
d = (index - x - len(x_grid) * y) / len(x_grid) / len(d_grid)
return x, y, d
for line in input_lines[1:]:
x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
x1_index = x_grid_index[x1]
x2_index = x_grid_index[x2]
y1_index = y_grid_index[y1]
y2_index = y_grid_index[y2]
d1_index = d_grid_index[d1]
d2_index = d_grid_index[d2]
for x in xrange(x1_index, x2_index):
for y in xrange(y1_index, y2_index):
for d in xrange(d1_index, d2_index):
fish_dist[index2arr(x,y,d)] += 1
volume = 0
for index, num in [x for x in enumerate(fish_dist) if x[1] >= K]:
x_index, y_index, d_index = arr2index(index)
x_begin = x_grid[x_index]
y_begin = y_grid[y_index]
d_begin = d_grid[d_index]
x_end = x_grid[x_index + 1]
y_end = y_grid[y_index + 1]
d_end = d_grid[d_index + 1]
volume += (x_end - x_begin) * (y_end - y_begin) * (d_end - d_begin)
print(volume) |
s207316810 | p00504 | u894114233 | 1484654879 | Python | Python | py | Runtime Error | 40000 | 6576 | 2041 | import sys
sys.setrecursionlimit(10**8)
def check(y,x):
if 0<=x<=w-1 and 0<=y<=h-1 and g[y][x]!="#":
return True
return False
def dfs(y,x,cnt,v):
global ans
if cnt>k:return -1
if y==h-1 and x==w-1 and cnt==k:
return v
if cnt==k:
for i in xrange(4):
if i==2 or i==3:continue
nxx=x+dx[i]
nyy=y+dy[i]
if not check(nyy,nxx):continue
if g[nyy][nxx]!=".":
su=0
f=0
if not visited[nyy][nxx]:
su=int(g[nyy][nxx])
visited[nyy][nxx]=True
f=1
ans=max(ans,dfs(nyy,nxx,cnt,v+su))
if f==1:
visited[nyy][nxx]=False
else:
ans=max(ans,dfs(nyy,nxx,cnt,v))
if y==h-1 and x==w-1 and cnt==k:
return v
for i in xrange(4):
nxx=x+dx[i]
nyy=y+dy[i]
if not check(nyy,nxx):continue
if i==0 or i==1:
if g[nyy][nxx]!=".":
su=0
f=0
if not visited[nyy][nxx]:
su=int(g[nyy][nxx])
visited[nyy][nxx]=True
f=1
ans=max(ans,dfs(nyy,nxx,cnt,v+su))
if f==1:
visited[nyy][nxx]=False
else:
ans=max(ans,dfs(nyy,nxx,cnt,v))
else:
if g[nyy][nxx]!=".":
su=0
f=0
if not visited[nyy][nxx]:
su=int(g[nyy][nxx])
visited[nyy][nxx]=True
f=1
ans=max(ans,dfs(nyy,nxx,cnt+1,v+su))
if f==1:
visited[nyy][nxx]=False
else:
ans=max(ans,dfs(nyy,nxx,cnt+1,v))
return ans
h,w,k=map(int,raw_input().split())
g=[raw_input() for _ in xrange(h)]
dx=(1,0,-1,0)
dy=(0,1,0,-1)
visited=[[False]*w for _ in xrange(h)]
ans=0
ans=dfs(0,0,0,0)
print(ans) |
s426919599 | p00504 | u352394527 | 1526982125 | Python | Python3 | py | Runtime Error | 110 | 5616 | 1843 | INF = 9
h, w, k = map(int,input().split())
maps = [list("#" * (w + 2))]
for i in range(h):
maps.append(list("#" + input() + "#"))
maps.append(list("#" * (w + 2)))
#スタートからそのマスまでに何度逆走する必要があるかのマップ
#root_map = [[INF] * (w + 2) for i in range(h + 2)]
#そのマスからゴールまでに何度逆走する必要があるかのマップ
reverse_map = [[INF] * (w + 2) for i in range(h + 2)]
#def root_search(x, y, score):
# if score < root_map[x][y]:
# root_map[x][y] = score
# if maps[x - 1][y] != "#":
# root_search(x - 1, y, score + 1)
# if maps[x + 1][y] != "#":
# root_search(x + 1, y, score)
# if maps[x][y - 1] != "#":
# root_search(x, y - 1, score + 1)
# if maps[x][y + 1] != "#":
# root_search(x, y + 1, score)
#
def reverse_search(x, y, score):
if score < reverse_map[x][y]:
reverse_map[x][y] = score
if maps[x - 1][y] != "#":
reverse_search(x - 1, y, score)
if maps[x + 1][y] != "#":
reverse_search(x + 1, y, score + 1)
if maps[x][y - 1] != "#":
reverse_search(x, y - 1, score)
if maps[x][y + 1] != "#":
reverse_search(x, y + 1, score + 1)
def search(x, y, score, rest):
if rest < reverse_map[x][y]:
return 0
temp = maps[x][y]
if maps[x][y] in [str(i) for i in range(1,10)]:
score += int(maps[x][y])
maps[x][y] = "."
a = b = c = d = 0
if rest > 0 and maps[x - 1][y] != "#":
a = search(x - 1, y, score, rest - 1)
if maps[x + 1][y] != "#":
b = search(x + 1, y, score, rest)
if rest > 0 and maps[x][y - 1] != "#":
c = search(x, y - 1, score, rest - 1)
if maps[x][y + 1] != "#":
d = search(x, y + 1, score, rest)
ret = max(score, a, b, c, d)
maps[x][y] = temp
return ret
#root_search(1, 1, 0)
reverse_search(h, w, 0)
print(search(1,1,0,k))
|
s068297383 | p00504 | u352394527 | 1526982198 | Python | Python3 | py | Runtime Error | 100 | 5624 | 1885 | import sys
sys.setrecursionlimit(1000000)
INF = 9
h, w, k = map(int,input().split())
maps = [list("#" * (w + 2))]
for i in range(h):
maps.append(list("#" + input() + "#"))
maps.append(list("#" * (w + 2)))
#スタートからそのマスまでに何度逆走する必要があるかのマップ
#root_map = [[INF] * (w + 2) for i in range(h + 2)]
#そのマスからゴールまでに何度逆走する必要があるかのマップ
reverse_map = [[INF] * (w + 2) for i in range(h + 2)]
#def root_search(x, y, score):
# if score < root_map[x][y]:
# root_map[x][y] = score
# if maps[x - 1][y] != "#":
# root_search(x - 1, y, score + 1)
# if maps[x + 1][y] != "#":
# root_search(x + 1, y, score)
# if maps[x][y - 1] != "#":
# root_search(x, y - 1, score + 1)
# if maps[x][y + 1] != "#":
# root_search(x, y + 1, score)
#
def reverse_search(x, y, score):
if score < reverse_map[x][y]:
reverse_map[x][y] = score
if maps[x - 1][y] != "#":
reverse_search(x - 1, y, score)
if maps[x + 1][y] != "#":
reverse_search(x + 1, y, score + 1)
if maps[x][y - 1] != "#":
reverse_search(x, y - 1, score)
if maps[x][y + 1] != "#":
reverse_search(x, y + 1, score + 1)
def search(x, y, score, rest):
if rest < reverse_map[x][y]:
return 0
temp = maps[x][y]
if maps[x][y] in [str(i) for i in range(1,10)]:
score += int(maps[x][y])
maps[x][y] = "."
a = b = c = d = 0
if rest > 0 and maps[x - 1][y] != "#":
a = search(x - 1, y, score, rest - 1)
if maps[x + 1][y] != "#":
b = search(x + 1, y, score, rest)
if rest > 0 and maps[x][y - 1] != "#":
c = search(x, y - 1, score, rest - 1)
if maps[x][y + 1] != "#":
d = search(x, y + 1, score, rest)
ret = max(score, a, b, c, d)
maps[x][y] = temp
return ret
#root_search(1, 1, 0)
reverse_search(h, w, 0)
print(search(1,1,0,k))
|
s403630988 | p00505 | u504401399 | 1531325339 | Python | Python3 | py | Runtime Error | 0 | 0 | 513 | lista=[]
t=0
ch=0
e=0
d=0
tflag=1
while True:
try:
lista.append(list(map(int,input().split())))
except:
break;
def func01(a,b,c):
global t
global ch
global e
global d
if a+b>c:
t+=1
if a**2+b**2==c**2:
ch+=1
elif a**2+b**2>c**2:
e+=1
elif a**2+b**2<c**2:
d+=1
else tflag=0
while(tflag==1):
for i in range(len(lista)):
x=sorted(lista[i])
func01(x[0],x[1],x[2])
print(t,ch,e,d)
|
s308070244 | p00505 | u504401399 | 1531325374 | Python | Python3 | py | Runtime Error | 0 | 0 | 514 | lista=[]
t=0
ch=0
e=0
d=0
tflag=1
while True:
try:
lista.append(list(map(int,input().split())))
except:
break;
def func01(a,b,c):
global t
global ch
global e
global d
if a+b>c:
t+=1
if a**2+b**2==c**2:
ch+=1
elif a**2+b**2>c**2:
e+=1
elif a**2+b**2<c**2:
d+=1
else tflag==0
while(tflag==1):
for i in range(len(lista)):
x=sorted(lista[i])
func01(x[0],x[1],x[2])
print(t,ch,e,d)
|
s422832058 | p00505 | u504401399 | 1531325410 | Python | Python3 | py | Runtime Error | 0 | 0 | 523 | lista=[]
t=0
ch=0
e=0
d=0
tflag=1
while True:
try:
lista.append(list(map(int,input().split())))
except:
break;
def func01(a,b,c):
global t
global ch
global e
global d
if a+b>c:
t+=1
if a**2+b**2==c**2:
ch+=1
elif a**2+b**2>c**2:
e+=1
elif a**2+b**2<c**2:
d+=1
else:
tflag==0
while(tflag==1):
for i in range(len(lista)):
x=sorted(lista[i])
func01(x[0],x[1],x[2])
print(t,ch,e,d)
|
s641800820 | p00505 | u504401399 | 1531325569 | Python | Python3 | py | Runtime Error | 0 | 0 | 522 | lista=[]
t=0
ch=0
e=0
d=0
tflag=1
while True:
try:
lista.append(list(map(int,input().split())))
except:
break;
def func01(a,b,c):
global t
global ch
global e
global d
if a+b>c:
t+=1
if a**2+b**2==c**2:
ch+=1
elif a**2+b**2>c**2:
e+=1
elif a**2+b**2<c**2:
d+=1
else:
tflag=0
while(tflag==1):
for i in range(len(lista)):
x=sorted(lista[i])
func01(x[0],x[1],x[2])
print(t,ch,e,d)
|
s544672734 | p00505 | u668055645 | 1545266364 | Python | Python3 | py | Runtime Error | 0 | 0 | 365 | f = True
cnt = 0
l = [0,0,0]
while f:
t = []
t.append(int(input()))
t.append(int(input()))
t.append(int(input()))
t.sort()
if t[0]+t[1] <= t[2]:
f = False
continue
if t[0]**2+t[1]**2 > t[2]**2:
l[0]+=1
elif t[0]**2+t[1]**2 == t[2]**2:
l[1]+=1
else:
l[2]+=1
print(sum(l),s for s in l)
|
s824507020 | p00505 | u668055645 | 1545266461 | Python | Python3 | py | Runtime Error | 0 | 0 | 367 | f = True
cnt = 0
l = [0,0,0]
while f:
t = []
t.append(int(input()))
t.append(int(input()))
t.append(int(input()))
t.sort()
if t[0]+t[1] <= t[2]:
f = False
continue
if t[0]**2+t[1]**2 > t[2]**2:
l[0]+=1
elif t[0]**2+t[1]**2 == t[2]**2:
l[1]+=1
else:
l[2]+=1
print(sum(l),[s for s in l])
|
s626386581 | p00505 | u471400255 | 1511192168 | Python | Python3 | py | Runtime Error | 0 | 0 | 598 | import sys
num = 0
triangle = {"chokkaku":0,"eikaku":0,"donkaku":0}
henn = sys.stdin.readlines()
for i in henn:
hen = list(map(int,i))
hen.sort()
if (hen[0] + hen[1] <= hen[2]) or (hen[1] + hen[2] <= hen[0]) or (hen[2] + hen[0] <= hen[1]):
break
else:
num += 1
if hen[0]**2 + hen[1] ** 2 == hen[2] **2:
triangle["chokkaku"] += 1
elif hen[0] ** 2 + hen[1] ** 2 < hen[2] **2:
triangle["donkaku"] += 1
else:
triangle["eikaku"] += 1
kotae = str(num)+" "+" ".join(list(map(str,triangle.values())))
print(kotae) |
s452365205 | p00505 | u234387950 | 1519107645 | Python | Python3 | py | Runtime Error | 0 | 0 | 810 | #input_f = "3 4 5\n2 1 2\n6 3 4\n1 1 1\n1 2 3"
input_f = input()
counter = [0, 0, 0]
def t_check(a,b,c):
if a + b > c:
if b + c > a:
if a + c > b: return True
return False
def f_check(a_, b_, c_):
tmp = []
tmp.append(a_)
tmp.append(b_)
tmp.append(c_)
sqrts = []
for i in range(3):
sqrts.append(tmp[i]**2)
m = max(sqrts)
s = sum(sqrts)
print(m,s)
if m == (s - m): return(0)
if m > (s - m): return(2)
if m < (s - m): return(1)
for i in range(int(len(input_f))):
t = input_f.split("\n")[i].split()
fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
if t_check(fn,sn,tn):
counter[f_check(fn,sn,tn)] += 1
else:
print(sum(counter),counter[0], counter[1], counter[2])
break
|
s228577235 | p00505 | u234387950 | 1519107685 | Python | Python3 | py | Runtime Error | 0 | 0 | 810 | #input_f = "3 4 5\n2 1 2\n6 3 4\n1 1 1\n1 2 3"
input_f = input()
counter = [0, 0, 0]
def t_check(a,b,c):
if a + b > c:
if b + c > a:
if a + c > b: return True
return False
def f_check(a_, b_, c_):
tmp = []
tmp.append(a_)
tmp.append(b_)
tmp.append(c_)
sqrts = []
for i in range(3):
sqrts.append(tmp[i]**2)
m = max(sqrts)
s = sum(sqrts)
print(m,s)
if m == (s - m): return(0)
if m > (s - m): return(2)
if m < (s - m): return(1)
for i in range(int(len(input_f))):
t = input_f.split("\n")[i].split()
fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
if t_check(fn,sn,tn):
counter[f_check(fn,sn,tn)] += 1
else:
print(sum(counter),counter[0], counter[1], counter[2])
break
|
s583143452 | p00505 | u234387950 | 1519107894 | Python | Python3 | py | Runtime Error | 0 | 0 | 851 | #input_f = "3 4 5\n2 1 2\n6 3 4\n1 1 1\n1 2 3"
while():
input_f = input()
counter = [0, 0, 0]
def t_check(a,b,c):
if a + b > c:
if b + c > a:
if a + c > b: return True
return False
def f_check(a_, b_, c_):
tmp = []
tmp.append(a_)
tmp.append(b_)
tmp.append(c_)
sqrts = []
for i in range(3):
sqrts.append(tmp[i]**2)
m = max(sqrts)
s = sum(sqrts)
print(m,s)
if m == (s - m): return(0)
if m > (s - m): return(2)
if m < (s - m): return(1)
t = input_f.split("\n")[i].split()
fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
if t_check(fn,sn,tn):
counter[f_check(fn,sn,tn)] += 1
else: break
print(sum(counter),counter[0], counter[1], counter[2])
|
s133077489 | p00505 | u234387950 | 1519108071 | Python | Python3 | py | Runtime Error | 0 | 0 | 786 | #input_f = "3 4 5\n2 1 2\n6 3 4\n1 1 1\n1 2 3"
def t_check(a,b,c):
if a + b > c:
if b + c > a:
if a + c > b: return True
return False
def f_check(a_, b_, c_):
tmp = []
tmp.append(a_)
tmp.append(b_)
tmp.append(c_)
sqrts = []
for i in range(3):
sqrts.append(tmp[i]**2)
m = max(sqrts)
s = sum(sqrts)
print(m,s)
if m == (s - m): return(0)
if m > (s - m): return(2)
if m < (s - m): return(1)
counter=[0,0,0]
while(1):
input_f = input()
t = input_f.split("\n")[i].split()
fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
if t_check(fn,sn,tn):
counter[f_check(fn,sn,tn)] += 1
else: break
print(sum(counter),counter[0], counter[1], counter[2])
|
s392399280 | p00505 | u234387950 | 1519108139 | Python | Python3 | py | Runtime Error | 0 | 0 | 770 | #input_f = "3 4 5\n2 1 2\n6 3 4\n1 1 1\n1 2 3"
def t_check(a,b,c):
if a + b > c:
if b + c > a:
if a + c > b: return True
return False
def f_check(a_, b_, c_):
tmp = []
tmp.append(a_)
tmp.append(b_)
tmp.append(c_)
sqrts = []
for i in range(3):
sqrts.append(tmp[i]**2)
m = max(sqrts)
s = sum(sqrts)
if m == (s - m): return(0)
if m > (s - m): return(2)
if m < (s - m): return(1)
counter=[0,0,0]
while(1):
input_f = input()
t = input_f.split("\n")[i].split()
fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
if t_check(fn,sn,tn):
counter[f_check(fn,sn,tn)] += 1
else: break
print(sum(counter),counter[0], counter[1], counter[2])
|
s992582301 | p00505 | u234387950 | 1519108246 | Python | Python3 | py | Runtime Error | 0 | 0 | 770 | #input_f = "3 4 5\n2 1 2\n6 3 4\n1 1 1\n1 2 3"
def t_check(a,b,c):
if a + b > c:
if b + c > a:
if a + c > b: return True
return False
def f_check(a_, b_, c_):
tmp = []
tmp.append(a_)
tmp.append(b_)
tmp.append(c_)
sqrts = []
for i in range(3):
sqrts.append(tmp[i]**2)
m = max(sqrts)
s = sum(sqrts)
if m == (s - m): return(0)
if m > (s - m): return(2)
if m < (s - m): return(1)
counter=[0,0,0]
while(1):
input_f = input()
t = input_f.split("\n")[i].split()
fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
if t_check(fn,sn,tn):
counter[f_check(fn,sn,tn)] += 1
else: break
print(sum(counter),counter[0], counter[1], counter[2])
|
s661768871 | p00505 | u234387950 | 1519108323 | Python | Python3 | py | Runtime Error | 0 | 0 | 770 | #input_f = "3 4 5\n2 1 2\n6 3 4\n1 1 1\n1 2 3"
def t_check(a,b,c):
if a + b > c:
if b + c > a:
if a + c > b: return True
return False
def f_check(a_, b_, c_):
tmp = []
tmp.append(a_)
tmp.append(b_)
tmp.append(c_)
sqrts = []
for i in range(3):
sqrts.append(tmp[i]**2)
m = max(sqrts)
s = sum(sqrts)
if m == (s - m): return(0)
if m > (s - m): return(2)
if m < (s - m): return(1)
counter=[0,0,0]
while(1):
input_f = input()
t = input_f.split("\n")[i].split()
fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
if t_check(fn,sn,tn):
counter[f_check(fn,sn,tn)] += 1
else: break
print(sum(counter),counter[0], counter[1], counter[2])
|
s687575487 | p00505 | u234387950 | 1519108691 | Python | Python3 | py | Runtime Error | 0 | 0 | 695 | def t_check(a,b,c):
if a + b > c:
if b + c > a:
if a + c > b: return True
return False
def f_check(a_, b_, c_):
tmp = []
tmp.append(a_)
tmp.append(b_)
tmp.append(c_)
sqrts = []
for i in range(3):
sqrts.append(tmp[i]**2)
m = max(sqrts)
s = sum(sqrts)
if m == (s - m): return(0)
if m > (s - m): return(2)
if m < (s - m): return(1)
counter=[0,0,0]
while(1):
input_f = input()
t = input_f.split("\n").split()
fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
if t_check(fn,sn,tn):
counter[f_check(fn,sn,tn)] += 1
else: break
print(sum(counter),counter[0], counter[1], counter[2])
|
s596865458 | p00505 | u899891332 | 1521759034 | Python | Python3 | py | Runtime Error | 0 | 0 | 347 | ans = [,,,]
while True:
sides = [,,]
for i in range(3):
side[i] = int(input())
sides = sorted(sides)
if sides[2] >= sides[1] + sides[0]:
print(ans[0], ans[1], ans[2], ans[3])
break
if sides[2]**2 >= sides[1]**2 + sides[0]**2:
ans[3]+=1
elif sides[2]**2 == sides[1]**2 + sides[0]**2:
ans[2]+=1
else:
ans[1]+=1
|
s711553672 | p00505 | u899891332 | 1521759201 | Python | Python3 | py | Runtime Error | 0 | 0 | 327 | ans = [0 for i in range(4)]
while True:
sides = sorted([int(input()) for i in range(3)])
if sides[2] >= sides[1] + sides[0]:
print(ans[0], ans[1], ans[2], ans[3])
break
if sides[2]**2 >= sides[1]**2 + sides[0]**2:
ans[3]+=1
elif sides[2]**2 == sides[1]**2 + sides[0]**2:
ans[2]+=1
else:
ans[1]+=1
|
s200477577 | p00505 | u346907393 | 1522138621 | Python | Python3 | py | Runtime Error | 0 | 0 | 501 | def checkTriangle(a, b, c):
if a + b > c and a + c > b and b + c > a:
return True
return False
def checkOct(a, b, c):
a, b, c = [i * i for i in [a, b, c]]
if a + b == c or a + c == b or b + c == a:
return 0
elif c < a + b or b < a + c or a < b + c:
return 1
else:
return 2
for i in range(5):
a, b, c = map(int, input())
result = [0] * 3
if checkTriangle(a, b, c):
result[checkOct(a, b, c)] += 1
print(sum(result),*result)
|
s693791271 | p00505 | u346907393 | 1522138868 | Python | Python3 | py | Runtime Error | 0 | 0 | 502 | def checkTriangle(a, b, c):
if a + b > c and a + c > b and b + c > a:
return True
return False
def checkOct(a, b, c):
a, b, c = [i * i for i in [a, b, c]]
if a + b == c or a + c == b or b + c == a:
return 0
elif c < a + b or b < a + c or a < b + c:
return 1
else:
return 2
for i in range(5):
#a, b, c = map(int, input())
result = [0] * 3
if checkTriangle(a, b, c):
result[checkOct(a, b, c)] += 1
print(sum(result),*result)
|
s065697169 | p00505 | u346907393 | 1522138879 | Python | Python3 | py | Runtime Error | 0 | 0 | 501 | def checkTriangle(a, b, c):
if a + b > c and a + c > b and b + c > a:
return True
return False
def checkOct(a, b, c):
a, b, c = [i * i for i in [a, b, c]]
if a + b == c or a + c == b or b + c == a:
return 0
elif c < a + b or b < a + c or a < b + c:
return 1
else:
return 2
for i in range(5):
a, b, c = map(int, input())
result = [0] * 3
if checkTriangle(a, b, c):
result[checkOct(a, b, c)] += 1
print(sum(result),*result)
|
s794692025 | p00505 | u346907393 | 1522139276 | Python | Python3 | py | Runtime Error | 0 | 0 | 303 | result = [0] * 3
while 1:
a, b, c = sorted(list(map(int, input().split())))
if a + b > c:
flag = c * c - b * b - a * a
if flag == 0:
result[0] += 1
elif flag > 0:
result[1] += 1
else:
result[2] += 1
print(sum(result), *result)
|
s907101015 | p00505 | u346907393 | 1522139316 | Python | Python3 | py | Runtime Error | 0 | 0 | 303 | result = [0] * 3
while 1:
a, b, c = sorted(list(map(int, input().split())))
if a + b > c:
flag = c * c - b * b - a * a
if flag == 0:
result[0] += 1
elif flag > 0:
result[1] += 1
else:
result[2] += 1
print(sum(result), *result)
|
s121923702 | p00505 | u346907393 | 1522139344 | Python | Python3 | py | Runtime Error | 0 | 0 | 71 | result = [0] * 3
while 1:
a = input()
#print(sum(result), *result)
|
s806572879 | p00505 | u346907393 | 1522139348 | Python | Python3 | py | Runtime Error | 0 | 0 | 71 | result = [0] * 3
while 1:
a = input()
#print(sum(result), *result)
|
s099339134 | p00505 | u346907393 | 1522139358 | Python | Python3 | py | Runtime Error | 0 | 0 | 71 | result = [0] * 3
while 1:
a = input()
#print(sum(result), *result)
|
s751525035 | p00505 | u346907393 | 1522139405 | Python | Python3 | py | Runtime Error | 0 | 0 | 71 | result = [0] * 3
while 1:
a = input()
#print(sum(result), *result)
|
s014459241 | p00505 | u346907393 | 1522139490 | Python | Python3 | py | Runtime Error | 0 | 0 | 303 | result = [0] * 3
while 1:
a, b, c = sorted(list(map(int, input().split())))
if a + b > c:
flag = c * c - b * b - a * a
if flag == 0:
result[0] += 1
elif flag > 0:
result[1] += 1
else:
result[2] += 1
print(sum(result), *result)
|
s838784809 | p00505 | u346907393 | 1522139821 | Python | Python3 | py | Runtime Error | 0 | 0 | 276 | result = [0]*3
while True:
a, b, c = sorted(map(int, input().split()))
if a + b <= c:
print(sum(result),*result)
flag = a ** 2 + b ** 2 - c*c
if flag == 0:
result[0] +=1
elif flag >0:
result[1] += 1
else:
result[2] += 1
|
s062899260 | p00505 | u346907393 | 1522139832 | Python | Python3 | py | Runtime Error | 0 | 0 | 277 | result = [0]*3
while True:
a, b, c = sorted(map(int, input().split()))
if a + b <= c:
#print(sum(result),*result)
flag = a ** 2 + b ** 2 - c*c
if flag == 0:
result[0] +=1
elif flag >0:
result[1] += 1
else:
result[2] += 1
|
s482554150 | p00505 | u150984829 | 1524907031 | Python | Python3 | py | Runtime Error | 0 | 0 | 158 | r=a=o=0
while 1:
l,m,n=sorted(list(map(int,input().split())))
if l+m<=n:break
c=l*l+m*m-n*n
if c>0:a+=1
elif c<0:o+=1
else:r+=1
print(sum(r,a,o),r,a,o)
|
s961556581 | p00505 | u742505495 | 1525161905 | Python | Python3 | py | Runtime Error | 0 | 0 | 283 | a,b,c,d = 0,0,0,0
while 1:
lng=list(int(input().split()))
lng.sort()
if lng[0] + lng[1] <= lng[2]:
print('%d %d %d %d' % (a,b,c,d))
break
else:
a += 1
if lng[0]**2 + lng[1]**2 == lng[2]**2:
b += 1
elif lng[0]**2 + lng[1]**2 >= lng[2]**2:
d += 1
else:
c += 1
|
s901300024 | p00505 | u126478680 | 1527366341 | Python | Python3 | py | Runtime Error | 0 | 0 | 747 | import sys
from enum import Enum, auto
class Triangle(Enum):
NOTRIANGLE = 0
ACUTE = 1
RIGHT = 2
OBTUSE = 3
def triangle_check(a, b, c):
e1, e2, e3 = sorted([a, b, c], reverse=True)
if e1 <= 0 or e2 <= 0 or e3 <= 0: return Triangle.NOTRIANGLE
if e1 < e2 + e3: return Triangle.NOTRIANGLE
if e1**2 == e2**2 + e3**2: return Triangle.RIGHT
elif e1**2 < e2**2 + e3**2: return Triangle.ACUTE
elif e1**2 > e2**2 + e3**2: return Triangle.OBTUSE
ans = [0 for i in range(4)]
lines = sys.stdin.readlines()
for line in lines:
a, b, c = list(map(int, line.split(' ')))
rst = triangle_check(a, b, c)
if rst == 0:
print(' '.join(list(map(str, ans))))
break
ans[0] += 1
ans[rst] += 1
|
s523440060 | p00505 | u126478680 | 1527366374 | Python | Python3 | py | Runtime Error | 0 | 0 | 752 | import sys
from enum import Enum, auto
class Triangle(Enum):
NOTRIANGLE = 0
ACUTE = 1
RIGHT = 2
OBTUSE = 3
def triangle_check(a, b, c):
e1, e2, e3 = sorted([a, b, c], reverse=True)
if e1 <= 0 or e2 <= 0 or e3 <= 0: return Triangle.NOTRIANGLE
if e1 < e2 + e3: return Triangle.NOTRIANGLE
if e1**2 == e2**2 + e3**2: return Triangle.RIGHT
elif e1**2 < e2**2 + e3**2: return Triangle.ACUTE
elif e1**2 > e2**2 + e3**2: return Triangle.OBTUSE
ans = [0 for i in range(4)]
lines = sys.stdin.readlines()
for line in lines:
a, b, c = list(map(int, line.split(' ')))
rst = triangle_check(a, b, c)
if rst == 0:
print(' '.join(list(map(str, ans))))
break
ans[0] += 1
ans[int(rst)] += 1
|
s983414582 | p00505 | u717754242 | 1528951760 | Python | Python3 | py | Runtime Error | 0 | 0 | 496 | import numpy
import re
import math
def main():
"""
テストコード実行
:return:
"""
tri = acu = obt = rig = 0
while True:
a, b, c = sorted(map(int, input().split()), reverse=True)
if abs(b - c) < a < b + c:
tri += 1
if (b ** 2 + c ** 2 - a ** 2) > 0: acu += 1
elif (b ** 2 + c ** 2 - a ** 2) == 0: rig += 1
elif (b ** 2 + c ** 2 - a ** 2) < 0: obt += 1
else:
print(" ".join([str(tri), str(acu), str(obt), str(rig)]))
exit()
if __name__ == '__main__':
main()
|
s686588843 | p00505 | u872428181 | 1529465587 | Python | Python3 | py | Runtime Error | 0 | 0 | 592 | sankaku = 0
tyokkaku = 0
eikaku = 0
donkaku = 0
inputed_line = input()
data_str = inputed_line.split(' ')
data = [int(i) for i in data_str]
while True:
if data[-1] < data[0] + data[1]:
sankaku += 1
if data[-1] ** 2 == data[0] ** 2 + data[1] ** 2:
tyokkaku += 1
elif data[-1] ** 2 < data[0] ** 2 + data[1] ** 2:
eikaku += 1
elif data[-1] ** 2 > data[0] ** 2 + data[1] ** 2:
donkaku += 1
else:
break
answer_list = [sankaku, tyokkaku, eikaku, donkaku]
answer_str = ' '.join(answer_list)
print(answer_str)
|
s269309774 | p00505 | u872428181 | 1529465684 | Python | Python3 | py | Runtime Error | 0 | 0 | 620 | sankaku = 0
tyokkaku = 0
eikaku = 0
donkaku = 0
while True:
inputed_line = input()
data_str = inputed_line.split(' ')
data = [int(i) for i in data_str]
data.sort()
if data[-1] < data[0] + data[1]:
sankaku += 1
if data[-1] ** 2 == data[0] ** 2 + data[1] ** 2:
tyokkaku += 1
elif data[-1] ** 2 < data[0] ** 2 + data[1] ** 2:
eikaku += 1
elif data[-1] ** 2 > data[0] ** 2 + data[1] ** 2:
donkaku += 1
else:
break
answer_list = [sankaku, tyokkaku, eikaku, donkaku]
answer_str = ' '.join(answer_list)
print(answer_str)
|
s348482076 | p00505 | u872428181 | 1529465887 | Python | Python3 | py | Runtime Error | 0 | 0 | 616 | sankaku = 0
tyokkaku = 0
eikaku = 0
donkaku = 0
while True:
inputed_line = input()
data_str = inputed_line.split(' ')
data = [int(i) for i in data_str]
data.sort()
if data[-1] < data[0] + data[1]:
sankaku += 1
if data[-1] ** 2 == data[0] ** 2 + data[1] ** 2:
tyokkaku += 1
elif data[-1] ** 2 < data[0] ** 2 + data[1] ** 2:
eikaku += 1
elif data[-1] ** 2 > data[0] ** 2 + data[1] ** 2:
donkaku += 1
else:
break
answer_list = [sankaku, tyokkaku, eikaku, donkaku]
answer_str = ' '.join(answer_list)
print(answer_str)
|
s207296169 | p00505 | u596145152 | 1530373794 | Python | Python | py | Runtime Error | 0 | 0 | 959 | A =[]
while True:
try:
A.append(sorted(list(map(int,input().split())),reverse=True))
except:
break
#または、quit(),os.exit()をして止める。
def triangle_types(X):
print(X)
num_of_acute = 0
num_of_right = 0
num_of_obtuse = 0
num_of_normal = 0
for i in range(len(X)):
a,b,c = [j for j in X[i]]
ans = b**2 + c**2 - a**2
if (a < b + c):
num_of_normal+=1
if (ans > 0):
num_of_acute+=1
elif (ans == 0):
num_of_right+=1
elif (ans < 0):
num_of_obtuse+=1
else:
print("{} {} {} {}".format(num_of_normal,num_of_right,num_of_acute,num_of_obtuse))
return
else:
print("{} {} {} {}".format(num_of_normal,num_of_right,num_of_acute,num_of_obtuse))
return
if __name__ == '__main__':
triangle_types(A)
|
s667322025 | p00505 | u596145152 | 1530374058 | Python | Python | py | Runtime Error | 0 | 0 | 959 | A =[]
while True:
try:
A.append(sorted(list(map(int,input().split())),reverse=True))
except:
break
#または、quit(),os.exit()をして止める。
def triangle_types(X):
print(X)
num_of_acute = 0
num_of_right = 0
num_of_obtuse = 0
num_of_normal = 0
for i in range(len(X)):
a,b,c = [j for j in X[i]]
ans = b**2 + c**2 - a**2
if (a < b + c):
num_of_normal+=1
if (ans > 0):
num_of_acute+=1
elif (ans == 0):
num_of_right+=1
elif (ans < 0):
num_of_obtuse+=1
else:
print("{} {} {} {}".format(num_of_normal,num_of_right,num_of_acute,num_of_obtuse))
return
else:
print("{} {} {} {}".format(num_of_normal,num_of_right,num_of_acute,num_of_obtuse))
return
if __name__ == '__main__':
triangle_types(A)
|
s825538093 | p00505 | u596145152 | 1530408287 | Python | Python | py | Runtime Error | 0 | 0 | 1124 | A =[]
while True:
try:
A.append(sorted(list(map(int,input().split())),reverse=True))
except:
break
#または、quit(),os.exit()をして止める。
def triangle_types(X):
print(X)
num_of_acute = 0
num_of_right = 0
num_of_obtuse = 0
num_of_normal = 0
for i in range(len(X)):
a,b,c = [j for j in X[i]]
ans = b**2 + c**2 - a**2
print("a:{},b+c:{}".format(a,b+c))
if (a < b + c and b < a + c and c < a + b):
num_of_normal+=1
if (ans > 0):
num_of_acute+=1
elif (ans == 0):
num_of_right+=1
elif (ans < 0):
num_of_obtuse+=1
else:
print("{} {} {} {}".format(num_of_normal,num_of_right,num_of_acute,num_of_obtuse))
return
else:
print("{} {} {} {}".format(num_of_normal,num_of_right,num_of_acute,num_of_obtuse))
return
print("{} {} {} {}".format(num_of_normal,num_of_right,num_of_acute,num_of_obtuse))
return
if __name__ == '__main__':
triangle_types(A)
|
s483598771 | p00506 | u546285759 | 1490677915 | Python | Python3 | py | Runtime Error | 0 | 0 | 426 | n = int(input())
values = list(map(int, input().split()))
minv = min(vs)+1
print(1)
i = 2
ng_value = [1]*minv
while i < minv:
if not 0 in [1 if values[k] % i == 0 else 0 for k in range(n)]:
print(i)
else:
for j in range(i, minv, i):
ng_value[j] = 0
b = True
for j in range(i+1, minv):
if ng_value[j]:
i = j
b = False
break
if b: break |
s056677593 | p00506 | u110280195 | 1522410303 | Python | Python3 | py | Runtime Error | 70 | 5600 | 195 | if __name__ == '__main__' :
n = int(input())
a,b = [int(i) for i in input().split(" ")]
for i in range(1,min(a,b)+1):
if((a % i == 0) and (b % i == 0)):
print(i)
|
s637477260 | p00506 | u269391636 | 1523285442 | Python | Python3 | py | Runtime Error | 0 | 0 | 468 | def gcd(x,y):
if x % y:
return(c(y,x%y))
else:
return(y)
def
n = int(input())
lis = list(map(int, input().split()))
if n == 2:
a, b = lis[0],lis[1]
an = gcd(a,b)
else:
a, b ,c = lis[0],lis[1], lis[2]
an = gcd(gcd(a,b),c)
anlis = [an]
while(True):
for i in range(2,an+1):
if an % i == 0:
anlis.append(an)
break
if an == 1:
break
anlis.sort()
ans = ""
for j in anlis:
ans += str(j)
ans += " "
ans = ans[:-1]
print(ans)
|
s688331041 | p00506 | u150984829 | 1524922665 | Python | Python3 | py | Runtime Error | 0 | 0 | 204 | input()
n=sorted(list(map(int,input().split())))
m=n[0]
a={}
for x in range(1,int(m**.5)+1):
if m%x==0:a|={x,m//x}
for c in sorted(list(a)):
for k in n[1:]:
if k%c:break
else:print(c)
|
s235275616 | p00507 | u898097781 | 1518748126 | Python | Python3 | py | Runtime Error | 0 | 0 | 233 | import sys
inputs = sys.stdin.readlines()
datum = []
for i, x in enumerate(inputs[1:]):
for y in inputs[i+2:]:
datum.append(int('{}{}'.format(x, y)))
datum.append(int('{}{}'.format(y, x)))
print sorted(datum)[2]
|
s789659567 | p00507 | u898097781 | 1518748521 | Python | Python3 | py | Runtime Error | 0 | 0 | 233 | import sys
inputs = sys.stdin.readlines()
datum = []
for i, x in enumerate(inputs[1:]):
for y in inputs[i+2:]:
datum.append(int('{}{}'.format(x, y)))
datum.append(int('{}{}'.format(y, x)))
print sorted(datum)[2]
|
s409428017 | p00507 | u898097781 | 1518748521 | Python | Python3 | py | Runtime Error | 0 | 0 | 233 | import sys
inputs = sys.stdin.readlines()
datum = []
for i, x in enumerate(inputs[1:]):
for y in inputs[i+2:]:
datum.append(int('{}{}'.format(x, y)))
datum.append(int('{}{}'.format(y, x)))
print sorted(datum)[2]
|
s981312621 | p00507 | u234387950 | 1519109903 | Python | Python3 | py | Runtime Error | 13940 | 7996 | 423 | order = 0
nums = []
g_len = int(input())
for i in range(g_len):
nums.append(input())
str_list = []
for i in range((g_len)):
for j in range((g_len)):
if i != j:
this = int(nums[i]+nums[j])
str_list.append(this)
x = []
c =0
for t in str_list:
c += 1
if c > 3:
if t < max(x):
x.append(t)
else: x.append(t)
x = sorted(x)
print(x[2])
|
s599428635 | p00507 | u859637829 | 1519319489 | Python | Python3 | py | Runtime Error | 930 | 5720 | 550 | def get_n():
return int(input())
def get_ns():
return [int(a) for a in input().split()]
import math
def main():
n = get_n()
ns = sorted(set([get_n() for _ in range(n)]))
top3 = [9999999999,9999999999,9999999999]
for i,a in enumerate(ns):
for j,b in enumerate(ns):
if i==j:
continue
keta = int(math.log10(b))+1
c = a*pow(10,keta)+b
if c <top3[2]:
top3 = sorted(top3+[c])[:-1]
print(top3[2])
if __name__ == '__main__':
main()
|
s459615159 | p00507 | u273843182 | 1521347560 | Python | Python3 | py | Runtime Error | 0 | 0 | 187 | import itertools
n = int(input())
a = sorted([int(input()) for i in range(n)])[:4]
b = []
for c,d in intertools.permutations(a,2):
b += [c * 10**len(str(d)) + d]
print(sorted(b)[2])
|
s908138922 | p00507 | u269391636 | 1523269709 | Python | Python3 | py | Runtime Error | 0 | 0 | 195 | n = input()
a = []
for i in range(n):
a.append(input())
a = a.sort()[:3]
b = []
for i in [0,1,2]:
for j in [0,1,2]:
if i != j:
b.append(int(str(a[i] + a[j])))
b.sort()
return(b[2])
|
s515980748 | p00507 | u269391636 | 1523270024 | Python | Python | py | Runtime Error | 0 | 0 | 194 | n = input()
a = []
for i in range(n):
a.append(input())
a = a.sort()[:3]
b = []
for i in [0,1,2]:
for j in [0,1,2]:
if i != j:
b.append(int(str(a[i] + a[j])))
b.sort()
print(b[2])
|
s932623829 | p00507 | u269391636 | 1523270084 | Python | Python3 | py | Runtime Error | 0 | 0 | 205 | n = int(input())
a = []
for i in range(n):
a.append(int(input()))
a = a.sort()[:3]
b = []
for i in [0,1,2]:
for j in [0,1,2]:
if i != j:
b.append(int(str(a[i] + a[j])))
b.sort()
print(b[2])
|
s120695585 | p00507 | u269391636 | 1523270146 | Python | Python3 | py | Runtime Error | 0 | 0 | 211 | n = int(input())
a = []
for i in range(n):
a.append(int(input()))
a = a.sort()
a = a[:3]
b = []
for i in [0,1,2]:
for j in [0,1,2]:
if i != j:
b.append(int(str(a[i] + a[j])))
b.sort()
print(b[2])
|
s476448816 | p00507 | u150984829 | 1524909120 | Python | Python3 | py | Runtime Error | 0 | 0 | 161 | a=sorted([int(input())for _ in[0]*int(input())])[:4]
b=[]
for i in range(3):
for d in a[i:4]:
c=a[i]
b+=[c*10**len(d)+d,d*10**len(c)+c]
print(sorted(b)[2])
|
s372457940 | p00507 | u104911888 | 1367975383 | Python | Python | py | Runtime Error | 20000 | 144296 | 798 | def permutations(iterable, r=None):
pool = tuple(iterable)
n = len(pool)
r = n if r is None else r
if r > n:
return
indices = range(n)
cycles = range(n, n-r, -1)
yield tuple(pool[i] for i in indices[:r])
while n:
for i in reversed(range(r)):
cycles[i] -= 1
if cycles[i] == 0:
indices[i:] = indices[i+1:] + indices[i:i+1]
cycles[i] = n - i
else:
j = cycles[i]
indices[i], indices[-j] = indices[-j], indices[i]
yield tuple(pool[i] for i in indices[:r])
break
else:
return
L=[input() for i in range(input())]
S=[]
for i in permutations(L,2):
S.append(int("".join(map(str,i))))
print sorted(S)[2] |
s801927325 | p00507 | u104911888 | 1367975810 | Python | Python | py | Runtime Error | 20000 | 5040 | 842 | def permutations(iterable, r=None):
pool = tuple(iterable)
n = len(pool)
r = n if r is None else r
if r > n:
return
indices = range(n)
cycles = range(n, n-r, -1)
yield tuple(pool[i] for i in indices[:r])
while n:
for i in reversed(range(r)):
cycles[i] -= 1
if cycles[i] == 0:
indices[i:] = indices[i+1:] + indices[i:i+1]
cycles[i] = n - i
else:
j = cycles[i]
indices[i], indices[-j] = indices[-j], indices[i]
yield tuple(pool[i] for i in indices[:r])
break
else:
return
L=[input() for i in range(input())]
S=[1000000000,1000000000,1000000000]
for i in permutations(L,2):
S.append(int("".join(map(str,i))))
S=sorted(S)[:3]
print S[2] |
s525296473 | p00507 | u104911888 | 1367975927 | Python | Python | py | Runtime Error | 20000 | 4924 | 197 | import itertools
L=[input() for i in range(input())]
S=[1000000000,1000000000,1000000000]
for i in itertools.permutations(L,2):
S.append(int("".join(map(str,i))))
S=sorted(S)[:3]
print S[2] |
s987994495 | p00508 | u324811972 | 1531905113 | Python | Python3 | py | Runtime Error | 0 | 0 | 460 | n = input()
i = 0
pointList = []
while(i<n):
point0 = input().split()
point = [int(point0[0]),int(point0[1])]
pointList.append(point)
i+=1
dist = 0
minX_diff = 2000000
minY_diff = 20000000
for i,point1 in enumerate(pointList):
for j,point2 in enumerate(pointList):
if(i!=j):
x_diff = abs(point1[0] - point2[0])
y_diff = abs(point1[1] - point2[1])
if(x_diff+y_diff<minX_diff+minY_diff):
dist = x_diff*x_diff + y_diff*y_diff
print(dist,'\n')
|
s574769248 | p00508 | u324811972 | 1531905124 | Python | Python3 | py | Runtime Error | 0 | 0 | 460 | n = input()
i = 0
pointList = []
while(i<n):
point0 = input().split()
point = [int(point0[0]),int(point0[1])]
pointList.append(point)
i+=1
dist = 0
minX_diff = 2000000
minY_diff = 20000000
for i,point1 in enumerate(pointList):
for j,point2 in enumerate(pointList):
if(i!=j):
x_diff = abs(point1[0] - point2[0])
y_diff = abs(point1[1] - point2[1])
if(x_diff+y_diff<minX_diff+minY_diff):
dist = x_diff*x_diff + y_diff*y_diff
print(dist,'\n')
|
s334533766 | p00508 | u324811972 | 1531905194 | Python | Python3 | py | Runtime Error | 0 | 0 | 477 | n = input()
i = 0
pointList = []
while(i<n):
point0 = input().split()
point = [int(point0[0]),int(point0[1])]
pointList.append(point)
i+=1
dist = 0
print(dist,'\n')
minX_diff = 2000000
minY_diff = 20000000
for i,point1 in enumerate(pointList):
for j,point2 in enumerate(pointList):
if(i!=j):
x_diff = abs(point1[0] - point2[0])
y_diff = abs(point1[1] - point2[1])
if(x_diff+y_diff<minX_diff+minY_diff):
dist = x_diff*x_diff + y_diff*y_diff
print(dist,'\n')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.