Submission #667483
Source Code Expand
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import itertools
import numpy
DS = [(1, 0), (-1, 0), (0, 1), (0, -1)]
H = 30
W = 30
class Solver(object):
def __init__(self, stage):
self.stage = stage
self.hands = None
self.init_hands()
def init_hands(self):
self.hands = []
def naive_solution(self):
for r, c in itertools.product(range(H), range(W)):
cell = self.stage[r, c]
if cell <= 0:
continue
for _ in range(cell):
self.hands.append((r + 1, c + 1))
self.stage[r, c] -= 1
def use_one_adj_solution(self):
for r0, c0 in itertools.product(range(H), range(W)):
cell = self.stage[r0, c0]
if cell <= 0:
continue
self.hands.append((r0 + 1, c0 + 1))
self.stage[r0, c0] -= 1
cell = self.stage[r0, c0]
for dr, dc in DS:
(r, c) = (r0 + dr, c0 + dc)
if r < 0 or r >= H:
continue
elif c < 0 or c >= W:
continue
elif 0 < self.stage[r, c] == cell:
self.hands.append((r + 1, c + 1))
self.stage[r, c] -= 1
self.naive_solution()
def main():
stage = numpy.array([list(map(int, input().split())) for _ in range(H)])
solver = Solver(stage)
solver.use_one_adj_solution()
for r, c in solver.hands:
print("{} {}".format(r, c))
if __name__ == '__main__':
main()
Submission Info
Submission Time |
|
Task |
A - 高橋君の山崩しゲーム |
User |
hamukichi |
Language |
Python (3.4.3) |
Score |
541359 |
Code Size |
1628 Byte |
Status |
AC |
Exec Time |
3614 ms |
Memory |
25560 KB |
Judge Result
Set Name |
test_01 |
test_02 |
test_03 |
test_04 |
test_05 |
test_06 |
test_07 |
test_08 |
test_09 |
test_10 |
Score / Max Score |
55574 / 100000 |
53244 / 100000 |
54830 / 100000 |
51897 / 100000 |
54811 / 100000 |
54593 / 100000 |
53723 / 100000 |
55331 / 100000 |
53819 / 100000 |
53537 / 100000 |
Status |
|
|
|
|
|
|
|
|
|
|
Set Name |
Test Cases |
test_01 |
subtask_01_01.txt |
test_02 |
subtask_01_02.txt |
test_03 |
subtask_01_03.txt |
test_04 |
subtask_01_04.txt |
test_05 |
subtask_01_05.txt |
test_06 |
subtask_01_06.txt |
test_07 |
subtask_01_07.txt |
test_08 |
subtask_01_08.txt |
test_09 |
subtask_01_09.txt |
test_10 |
subtask_01_10.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask_01_01.txt |
AC |
3614 ms |
25560 KB |
subtask_01_02.txt |
AC |
444 ms |
16008 KB |
subtask_01_03.txt |
AC |
416 ms |
15900 KB |
subtask_01_04.txt |
AC |
439 ms |
16156 KB |
subtask_01_05.txt |
AC |
419 ms |
15900 KB |
subtask_01_06.txt |
AC |
425 ms |
16028 KB |
subtask_01_07.txt |
AC |
435 ms |
16004 KB |
subtask_01_08.txt |
AC |
441 ms |
15864 KB |
subtask_01_09.txt |
AC |
440 ms |
16008 KB |
subtask_01_10.txt |
AC |
439 ms |
16068 KB |