結果
問題 |
No.2432 Flip and Move
|
ユーザー |
|
提出日時 | 2025-05-24 00:10:38 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,638 bytes |
コンパイル時間 | 538 ms |
コンパイル使用メモリ | 82,652 KB |
実行使用メモリ | 568,108 KB |
最終ジャッジ日時 | 2025-05-24 00:11:21 |
合計ジャッジ時間 | 40,463 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 TLE * 3 MLE * 1 |
ソースコード
## https://yukicoder.me/problems/no/669 def solve(H_, W_, K): s_map = {} s_array = [] r = (0, 0) ind = 0 while r not in s_map: s_map[r] = ind s_array.append(r) r = ((r[0] + 1) % H_, (r[1] + 1) % W_) ind += 1 ans_map = {} if ind >= K: for i in range(K): s = s_array[i] ans_map[s] = 1 return ans_map else: s_ind = s_map[r] cycle = ind - s_ind # 初手の動き for i in range(s_ind): s = s_array[i] ans_map[s] = 1 K -= s_ind # 周期 k = K // cycle for i in range(s_ind, ind): s = s_array[i] ans_map[s] = k # 最後っ屁 k0 = K - cycle * k for i in range(k0): s = s_array[i + s_ind] if s not in ans_map: ans_map[s] = 0 ans_map[s] += 1 return ans_map def main(): H, W = map(int, input().split()) K = int(input()) H_ = 2 * H W_ = 2 * W ans_map = solve(H_, W_, K) cell = [[0] * W for _ in range(H)] for key, value in ans_map.items(): h0, w0 = key h = h0 if h0 < H else H_ - h0 - 1 w = w0 if w0 < W else W_ - w0 - 1 cell[h][w] += value for h in range(H): for w in range(W): v = cell[h][w] if v % 2 == 0: cell[h][w] = "." else: cell[h][w] = "#" for h in range(H): row = "".join(cell[h]) print(row) if __name__ == "__main__": main()