結果

問題 No.2432 Flip and Move
ユーザー sotanishysotanishy
提出日時 2023-08-18 23:09:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 623 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 199,056 KB
最終ジャッジ日時 2023-08-18 23:09:58
合計ジャッジ時間 15,406 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,300 KB
testcase_01 AC 76 ms
71,412 KB
testcase_02 AC 293 ms
119,404 KB
testcase_03 AC 623 ms
199,056 KB
testcase_04 AC 145 ms
116,464 KB
testcase_05 AC 166 ms
116,260 KB
testcase_06 AC 218 ms
99,432 KB
testcase_07 AC 438 ms
157,248 KB
testcase_08 AC 477 ms
164,108 KB
testcase_09 AC 568 ms
195,012 KB
testcase_10 AC 190 ms
103,908 KB
testcase_11 AC 240 ms
107,888 KB
testcase_12 AC 185 ms
100,188 KB
testcase_13 AC 229 ms
107,656 KB
testcase_14 AC 245 ms
105,724 KB
testcase_15 AC 537 ms
178,184 KB
testcase_16 AC 291 ms
93,424 KB
testcase_17 AC 428 ms
112,852 KB
testcase_18 AC 238 ms
88,076 KB
testcase_19 AC 386 ms
104,844 KB
testcase_20 AC 446 ms
116,268 KB
testcase_21 AC 442 ms
103,760 KB
testcase_22 AC 352 ms
107,100 KB
testcase_23 AC 211 ms
86,572 KB
testcase_24 AC 489 ms
110,820 KB
testcase_25 AC 370 ms
102,156 KB
testcase_26 AC 305 ms
108,352 KB
testcase_27 AC 151 ms
79,748 KB
testcase_28 AC 174 ms
78,892 KB
testcase_29 AC 419 ms
102,916 KB
testcase_30 AC 487 ms
113,704 KB
testcase_31 AC 340 ms
106,084 KB
testcase_32 AC 178 ms
80,472 KB
testcase_33 AC 489 ms
113,032 KB
testcase_34 AC 326 ms
95,988 KB
testcase_35 AC 254 ms
102,656 KB
testcase_36 AC 76 ms
71,288 KB
testcase_37 AC 78 ms
71,484 KB
testcase_38 AC 80 ms
71,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


def enc(i, j, S):
    return 4*(W*i+j)+S


def move(i, j, S):
    di = -1 if S & 1 else 1
    if 0 <= i + di < H:
        i += di
    else:
        S ^= 1
    dj = -1 if S & 2 else 1
    if 0 <= j + dj < W:
        j += dj
    else:
        S ^= 2
    return i, j, S


H, W = map(int, input().split())
K = int(input())
ans = [[0] * W for _ in range(H)]
time = [-1] * (4*H*W)
t = i = j = S = 0
while time[enc(i, j, S)] == -1:
    time[enc(i, j, S)] = t
    t += 1
    ans[i][j] ^= 1
    i, j, S = move(i, j, S)


t1 = time[enc(i, j, S)]
dt = t - t1
n, t2 = divmod(K - t1, dt)

for _ in range(dt):
    ans[i][j] ^= n % 2
    i, j, S = move(i, j, S)
for _ in range(t2):
    ans[i][j] ^= 1
    i, j, S = move(i, j, S)

for row in ans:
    print(''.join(map(lambda x: ".#"[x], row)))
0