結果

問題 No.2432 Flip and Move
ユーザー sotanishysotanishy
提出日時 2023-08-18 23:09:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 458 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 197,880 KB
最終ジャッジ日時 2024-05-06 05:42:31
合計ジャッジ時間 11,998 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 36 ms
51,712 KB
testcase_02 AC 186 ms
117,908 KB
testcase_03 AC 458 ms
197,880 KB
testcase_04 AC 98 ms
115,412 KB
testcase_05 AC 97 ms
115,456 KB
testcase_06 AC 166 ms
97,952 KB
testcase_07 AC 355 ms
155,972 KB
testcase_08 AC 356 ms
162,668 KB
testcase_09 AC 451 ms
193,440 KB
testcase_10 AC 150 ms
102,364 KB
testcase_11 AC 168 ms
106,132 KB
testcase_12 AC 142 ms
98,408 KB
testcase_13 AC 181 ms
106,844 KB
testcase_14 AC 181 ms
104,760 KB
testcase_15 AC 380 ms
176,620 KB
testcase_16 AC 222 ms
92,852 KB
testcase_17 AC 365 ms
110,980 KB
testcase_18 AC 178 ms
87,348 KB
testcase_19 AC 305 ms
103,488 KB
testcase_20 AC 349 ms
115,120 KB
testcase_21 AC 334 ms
102,700 KB
testcase_22 AC 270 ms
106,240 KB
testcase_23 AC 159 ms
85,624 KB
testcase_24 AC 384 ms
109,508 KB
testcase_25 AC 304 ms
101,032 KB
testcase_26 AC 236 ms
107,416 KB
testcase_27 AC 105 ms
78,572 KB
testcase_28 AC 123 ms
77,600 KB
testcase_29 AC 314 ms
101,888 KB
testcase_30 AC 351 ms
112,740 KB
testcase_31 AC 254 ms
104,996 KB
testcase_32 AC 128 ms
79,464 KB
testcase_33 AC 394 ms
111,740 KB
testcase_34 AC 228 ms
94,920 KB
testcase_35 AC 203 ms
101,592 KB
testcase_36 AC 37 ms
51,968 KB
testcase_37 AC 36 ms
51,712 KB
testcase_38 AC 39 ms
52,864 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