結果

問題 No.2339 Factorial Paths
ユーザー sotanishysotanishy
提出日時 2023-06-02 23:07:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 110,368 KB
最終ジャッジ日時 2023-08-28 05:36:41
合計ジャッジ時間 10,235 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
93,164 KB
testcase_01 AC 125 ms
93,132 KB
testcase_02 AC 129 ms
93,192 KB
testcase_03 AC 126 ms
93,248 KB
testcase_04 AC 126 ms
93,140 KB
testcase_05 AC 124 ms
93,144 KB
testcase_06 AC 125 ms
93,160 KB
testcase_07 AC 124 ms
93,316 KB
testcase_08 AC 127 ms
93,868 KB
testcase_09 AC 128 ms
93,700 KB
testcase_10 AC 131 ms
93,944 KB
testcase_11 AC 147 ms
109,388 KB
testcase_12 AC 148 ms
109,384 KB
testcase_13 AC 151 ms
109,528 KB
testcase_14 AC 156 ms
109,320 KB
testcase_15 AC 171 ms
109,828 KB
testcase_16 AC 191 ms
110,368 KB
testcase_17 AC 199 ms
110,312 KB
testcase_18 AC 203 ms
109,888 KB
testcase_19 AC 203 ms
110,148 KB
testcase_20 AC 207 ms
110,088 KB
testcase_21 AC 203 ms
110,320 KB
testcase_22 AC 205 ms
110,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
import sys
input = sys.stdin.readline


N = int(input())
M = 2000
grid = [[1] * M for _ in range(M)]
grid[0][0]=0


def f(N, i, j):
    if N == 1:
        return i, j
    h = N//2
    w = N-h
    for k in range(h+1):
        for l in range(w+1):
            grid[i+k][j+l] = 0
    i += h
    j += w
    i, j = f(h, i, j)
    i, j = f(w, i, j)
    return i, j


i, j = f(N, 0, 0)
H = i + 1
W = j + 1
print(H, W)
for row in grid[:H]:
    print("".join(map(lambda x: ".#"[x], row[:W])))
0