結果

問題 No.2339 Factorial Paths
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-06-02 23:13:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 1,100 bytes
コンパイル時間 1,147 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 99,664 KB
最終ジャッジ日時 2023-08-28 05:43:46
合計ジャッジ時間 11,053 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,624 KB
testcase_01 AC 91 ms
71,396 KB
testcase_02 AC 91 ms
71,280 KB
testcase_03 AC 92 ms
71,492 KB
testcase_04 AC 93 ms
71,488 KB
testcase_05 AC 92 ms
71,428 KB
testcase_06 AC 91 ms
71,552 KB
testcase_07 AC 92 ms
71,348 KB
testcase_08 AC 94 ms
71,388 KB
testcase_09 AC 91 ms
71,660 KB
testcase_10 AC 100 ms
77,104 KB
testcase_11 AC 104 ms
77,188 KB
testcase_12 AC 105 ms
77,520 KB
testcase_13 AC 111 ms
77,976 KB
testcase_14 AC 113 ms
77,648 KB
testcase_15 AC 133 ms
78,384 KB
testcase_16 AC 170 ms
94,132 KB
testcase_17 AC 189 ms
99,424 KB
testcase_18 AC 191 ms
99,664 KB
testcase_19 AC 201 ms
99,468 KB
testcase_20 AC 191 ms
99,448 KB
testcase_21 AC 195 ms
99,516 KB
testcase_22 AC 195 ms
99,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

4000 C 2000 通りが最大である


2N C N

"""

import sys
from sys import stdin
from collections import deque

N = int(stdin.readline())

if N == 1:
    print (1,1)
    print (".")
    sys.exit()

lis = []

q = deque([N])

while q:

    v = q.popleft()

    if v == 1:
        continue
    elif v == 2:
        lis.append( (2,2) )
    else:
        a = v // 2
        b = v - a

        lis.append( (a+1,b+1) )

        q.append( a )
        q.append( b )

s = 0
for a,b in lis:

    s += min(a,b)

H = 1
W = 1

for a,b in lis:

    a,b = min(a,b),max(b,a)

    if H >= W:
        H += a-1
        W += b-1
    else:
        H += b-1
        W += a-1

ans = [ ["#"] * W for i in range(H) ]

H = 1
W = 1

for a,b in lis:

    a,b = min(a,b),max(b,a)

    if H >= W:
        for i in range(a):
            for j in range(b):
                ans[H-1+i][W-1+j] = "."
        H += a-1
        W += b-1
    else:
        for j in range(a):
            for i in range(b):
                ans[H-1+i][W-1+j] = "."
        H += b-1
        W += a-1

print (H,W)
for i in ans:
    print ("".join(i))
0