updated to my failing solution
This commit is contained in:
parent
8c7b4e0deb
commit
92e372c55b
@ -29,16 +29,46 @@ bombs = []
|
|||||||
for line in range(K):
|
for line in range(K):
|
||||||
x, y = [int(i) for i in sys.stdin.readline().strip().split()]
|
x, y = [int(i) for i in sys.stdin.readline().strip().split()]
|
||||||
board[x][y] = True
|
board[x][y] = True
|
||||||
bombs.append([x, y])
|
bombs.append((x, y))
|
||||||
|
|
||||||
click = [int(i) for i in sys.stdin.readline().strip().split()]
|
click = tuple(int(i) for i in sys.stdin.readline().strip().split())
|
||||||
print click # XXX
|
if click in bombs:
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
counts = defaultdict(int)
|
adjacent_to_bombs = defaultdict(int)
|
||||||
for bomb in bombs:
|
for bomb in bombs:
|
||||||
for ni, nj in around(*bomb):
|
for ni, nj in around(*bomb):
|
||||||
if ni >= 0 and nj >= 0 and ni < N and nj < M and [ni, nj] not in bombs:
|
if ni >= 0 and nj >= 0 and ni < N and nj < M and [ni, nj] not in bombs:
|
||||||
counts[ni, nj] += 1
|
adjacent_to_bombs[ni, nj] += 1
|
||||||
|
|
||||||
|
if tuple(click) in adjacent_to_bombs.keys():
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
for line in board:
|
for line in board:
|
||||||
print line
|
print line
|
||||||
|
|
||||||
|
unobscured = {}
|
||||||
|
|
||||||
|
visited = {}
|
||||||
|
|
||||||
|
|
||||||
|
def seek_and_destroy(dude, unobscured):
|
||||||
|
if dude in unobscured:
|
||||||
|
return
|
||||||
|
unobscured[dude] = True
|
||||||
|
to_recurse = {}
|
||||||
|
for ni, nj in around(*dude):
|
||||||
|
if (ni >= 0 and nj >= 0 and ni < N and nj < M) and \
|
||||||
|
((ni, nj) not in bombs):
|
||||||
|
candidate = (ni, nj)
|
||||||
|
unobscured[candidate] = True
|
||||||
|
to_recurse[candidate] = True
|
||||||
|
print ">>>", to_recurse.keys()
|
||||||
|
for c in to_recurse.keys():
|
||||||
|
seek_and_destroy(c, unobscured)
|
||||||
|
|
||||||
|
seek_and_destroy(click, unobscured)
|
||||||
|
|
||||||
|
print "\n\n"
|
||||||
|
|
||||||
|
print "\n".join('{} {}'.format(*i) for i in sorted(unobscured.keys()))
|
||||||
|
Loading…
Reference in New Issue
Block a user