結果
問題 |
No.2432 Flip and Move
|
ユーザー |
|
提出日時 | 2025-05-24 00:17:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,222 ms / 2,000 ms |
コード長 | 1,782 bytes |
コンパイル時間 | 493 ms |
コンパイル使用メモリ | 82,340 KB |
実行使用メモリ | 433,080 KB |
最終ジャッジ日時 | 2025-05-24 00:18:29 |
合計ジャッジ時間 | 24,962 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
## https://yukicoder.me/problems/no/669 def solve(H_, W_, K): s_map = {} s_array = [] r = 0 ind = 0 while r not in s_map: s_map[r] = ind s_array.append(r) h = r // W_ w = r % W_ h = (h + 1) % H_ w = (w + 1) % W_ r = h * W_ + w ind += 1 s_ind = s_map[r] s_map = {} if ind >= K: for i in range(K): s = s_array[i] s_map[s] = 1 return s_map else: cycle = ind - s_ind # 初手の動き for i in range(s_ind): s = s_array[i] s_map[s] = 1 K -= s_ind # 周期 k = K // cycle for i in range(s_ind, ind): s = s_array[i] s_map[s] = k # 最後っ屁 k0 = K - cycle * k for i in range(k0): s = s_array[i + s_ind] if s not in s_map: s_map[s] = 0 s_map[s] += 1 return s_map def main(): H, W = map(int, input().split()) K = int(input()) H_ = 2 * H W_ = 2 * W ans_map = solve(H_, W_, K) for h in range(H): row = [] for w in range(W): r1 = h * W_ + w r2 = h * W_ + (W_ - 1 - w) r3 = (H_ - 1 - h) * W_ + w r4 = (H_ - 1 - h) * W_ + (W_ - 1 - w) a = 0 if r1 in ans_map: a += ans_map[r1] if r2 in ans_map: a += ans_map[r2] if r3 in ans_map: a += ans_map[r3] if r4 in ans_map: a += ans_map[r4] row.append("." if a % 2 == 0 else "#") print("".join(row)) if __name__ == "__main__": main()