AtCoder Regular Contest 080: D - Grid Coloring
solution
ヘビ。$O(HW)$。平面上のロシアゲー(構築ゲー)を解くためのそこそこ一般的なテクについて - Learning Algorithms。
implementation
#!/usr/bin/env python3
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
i = 0
for y in range(h):
row = []
for _ in range(w):
row += [ i + 1 ]
a[i] -= 1
if a[i] == 0:
i += 1
if y % 2 == 1:
row = reversed(row)
print(*row)