48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
import sys
|
|
|
|
W = H = 4_000_000
|
|
if len(sys.argv)>1: # sample
|
|
W = H = 20
|
|
|
|
# store position that are not reachable, row by row
|
|
L = [ [(0,0) for _ in range(32)] for _ in range(H+1) ]
|
|
|
|
|
|
for i,l in enumerate(sys.stdin.read().splitlines()):
|
|
(_,_,X,Y,_,_,_,_,A,J) = l.split(" ")
|
|
x = int(X[2:-1])
|
|
y = int(Y[2:-1])
|
|
a = int(A[2:-1])
|
|
b = int(J[2:])
|
|
d = abs(x-a)+abs(y-b)
|
|
for ny in range(y-d, y+d+1):
|
|
if ny>=0 and ny<=H:
|
|
dy = abs(ny-y)
|
|
dx = d-dy
|
|
L[ny][i] = (x-dx,x+dx)
|
|
#L[ny] = intesec(L[ny], (x-dy,x+dy))
|
|
|
|
|
|
if len(sys.argv)>1: # sample
|
|
for l in L:
|
|
print(l)
|
|
|
|
d=0
|
|
for (y,I) in enumerate(L):
|
|
SI = sorted(I)
|
|
maxx = 0
|
|
for (a,b) in SI:
|
|
if a>maxx+1:
|
|
d+=1
|
|
print(y, maxx+1, (maxx+1)*4_000_000+y)
|
|
maxx = max(maxx,b)
|
|
print(d) # should be 1
|
|
|
|
#< 2_855_041 2_911_365 11645462855041
|
|
#< 11645462855040
|
|
#< 2_855_041 2_911_363 11645454855041
|
|
#X 2_855_040 2_911_363 11645454855040
|
|
#> 2_855_041 2_911_362 11645450855041
|
|
|
|
# terminate well but wrong answer
|