starting clear the way
This commit is contained in:
parent
682b2825da
commit
b7795a2938
44
clear-the-way/clear_the_way.py
Normal file
44
clear-the-way/clear_the_way.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import sys
|
||||||
|
from collections import defaultdict
|
||||||
|
from itertools import product
|
||||||
|
|
||||||
|
|
||||||
|
_around_stencil = [(i, j) for i, j in product([-1, 0, 1], repeat=2)
|
||||||
|
if (i, j) != (0, 0)]
|
||||||
|
|
||||||
|
|
||||||
|
def empty_board(n, m):
|
||||||
|
board = []
|
||||||
|
for i in xrange(N):
|
||||||
|
board.append([False] * m)
|
||||||
|
return board
|
||||||
|
|
||||||
|
|
||||||
|
def around(I, J):
|
||||||
|
def f(i, j):
|
||||||
|
for _i, _j in _around_stencil:
|
||||||
|
yield (i + _i, j + _j)
|
||||||
|
return f(I, J)
|
||||||
|
|
||||||
|
|
||||||
|
N, M, K = [int(i) for i in sys.stdin.readline().split()]
|
||||||
|
|
||||||
|
board = empty_board(N, M)
|
||||||
|
bombs = []
|
||||||
|
|
||||||
|
for line in range(K):
|
||||||
|
x, y = [int(i) for i in sys.stdin.readline().strip().split()]
|
||||||
|
board[x][y] = True
|
||||||
|
bombs.append([x, y])
|
||||||
|
|
||||||
|
click = [int(i) for i in sys.stdin.readline().strip().split()]
|
||||||
|
print click # XXX
|
||||||
|
|
||||||
|
counts = defaultdict(int)
|
||||||
|
for bomb in bombs:
|
||||||
|
for ni, nj in around(*bomb):
|
||||||
|
if ni >= 0 and nj >= 0 and ni < N and nj < M and [ni, nj] not in bombs:
|
||||||
|
counts[ni, nj] += 1
|
||||||
|
|
||||||
|
for line in board:
|
||||||
|
print line
|
4
clear-the-way/stdin1.txt
Normal file
4
clear-the-way/stdin1.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
3 3 2
|
||||||
|
0 0
|
||||||
|
0 1
|
||||||
|
2 2
|
Loading…
Reference in New Issue
Block a user