54 lines
1.1 KiB
Python
54 lines
1.1 KiB
Python
|
import sys
|
||
|
from collections import defaultdict
|
||
|
|
||
|
|
||
|
W = H = 4*1000*1000+1
|
||
|
|
||
|
def mtn(P,Q):
|
||
|
(x,y) = P
|
||
|
(u,v) = Q
|
||
|
return abs(u-x)+abs(v-y)
|
||
|
|
||
|
P = dict()
|
||
|
|
||
|
for l in sys.stdin.read().splitlines():
|
||
|
(_,_,X,Y,_,_,_,_,A,J) = l.split(" ")
|
||
|
x = int(X[2:-1]) #+ 2
|
||
|
y = int(Y[2:-1])
|
||
|
a = int(A[2:-1]) #+ 2
|
||
|
b = int(J[2:])
|
||
|
P[(x,y)] = (a,b)
|
||
|
|
||
|
if len(P) < 20:
|
||
|
print("S -> B", P)
|
||
|
|
||
|
|
||
|
if len(P) < 20:
|
||
|
W = H = 30
|
||
|
|
||
|
M = [ [1 for _ in range(W) ] for _ in range(H) ]
|
||
|
|
||
|
|
||
|
for s,sB in P.items():
|
||
|
(x,y) = s
|
||
|
dB = mtn(s,sB) # max range before first bc
|
||
|
if len(P) < 20:
|
||
|
print(s, sB, dB)
|
||
|
for rx in range(dB+1):
|
||
|
for ry in range(dB-rx+1):
|
||
|
for (nx,ny) in [(x-rx,y-ry),(x-rx,y+ry),(x+rx,y-ry),(x+rx,y+ry)]:
|
||
|
if nx>=0 and nx<W and ny>=0 and ny<H:
|
||
|
M[ny][nx] = 0
|
||
|
|
||
|
for y,r in enumerate(M):
|
||
|
for x,c in enumerate(r):
|
||
|
if c == 0:
|
||
|
if len(P)>20:
|
||
|
print(x,y)
|
||
|
pass
|
||
|
|
||
|
if len(P) < 20:
|
||
|
print("\n".join(" ".join(str(i) for i in l) for l in M))
|
||
|
|
||
|
# take too much memory
|