import sys
n, m = [int(x) for x in sys.stdin.readline().split()]
f = []
for _ in range(n): f += [int(x) for x in sys.stdin.readline().split()]
v = f.index(min(f))
y, x, r = v // m, v % m, 0
while(1):
ind = y * m + x
r += f[ind]
f[ind] = -1
c = [[y, x+1], [y+1, x], [y, x-1], [y-1, x]]
c = [z for z in c if z[0] >= 0 and z[0] < n and z[1] >= 0 and z[1] < m]
if(not c): break
c = [(z[0], z[1], f[z[0] * m + z[1]]) for z in c]
c = [z for z in c if z[2] >= 0]
if(not c): break
c.sort(key = lambda z: z[2])
y, x, _ = c[0]
print(r)
2020/06/24
[zerojudge] e287: 機器人的路徑
2020/06/13
[zerojudge] e990: 奇怪的隕石
from sys import *
from math import log
for s in stdin:
t, n = map(float, s.split())
r = (log(n)/log(0.5))*t
print('%.3f' % r)
[zerojudge] a225 明明愛排列
import sys
for s in sys.stdin: print(' '.join(sorted(sys.stdin.readline().strip().split(), key = lambda x: (int(x)%10, -int(x)))))
訂閱:
文章 (Atom)