結果
| 問題 |
No.2432 Flip and Move
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-24 00:12:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,616 bytes |
| コンパイル時間 | 557 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 535,112 KB |
| 最終ジャッジ日時 | 2025-05-24 00:13:37 |
| 合計ジャッジ時間 | 7,360 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 TLE * 1 MLE * 3 |
ソースコード
## 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
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)
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()