23 lines
544 B
Python
23 lines
544 B
Python
|
import sys
|
||
|
L = list(list(map(int,s)) for s in sys.stdin.read().splitlines())
|
||
|
W = len(L[0]) ; H = len(L)
|
||
|
size = W * H
|
||
|
Q = 0
|
||
|
def check(rows, cols):
|
||
|
global Q
|
||
|
h = -1
|
||
|
for r in rows:
|
||
|
for c in cols:
|
||
|
if L[r][c] > h:
|
||
|
V[r * W + c] = True
|
||
|
h = L[r][c]
|
||
|
Q += 1
|
||
|
|
||
|
V = [False for _ in range(size)]
|
||
|
for r in range(H):
|
||
|
check([r], range(W))
|
||
|
check([r], range(W-1, -1, -1))
|
||
|
for c in range(W):
|
||
|
check(range(H), [c])
|
||
|
check(range(H-1, -1, -1), [c])
|
||
|
print(sum(V), 2*(H*W+W*H), Q)
|