2019-01-22から1日間の記事一覧

AtCoder Beginner Contest 045 D - すぬけ君の塗り絵 / Snuke's Coloring

これは割とすんなり解けたかな。 from collections import Counter def solve(H, W, N, ABs): total = (H - 2) * (W - 2) points = {} for a, b in ABs: a -= 1 b -= 1 for i in [-1, 0, 1]: for j in [-1, 0, 1]: if 0 < a + i < H - 1 and 0 < b + j < W -…

AtCoder Beginner Contest 043 D - アンバランス / Unbalanced

400点問題だからと言って実装が必ず大変ってわけでもない。 def solve(s): for i, j in zip(range(0, len(s) - 1), range(1, len(s))): if s[i] == s[j]: return "%d %d" % (i + 1, j + 1) for i, j in zip(range(0, len(s) - 2), range(2, len(s))): if s[i…