結果

問題 No.883 ぬりえ
ユーザー kohei2019kohei2019
提出日時 2022-05-06 11:57:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 88,956 KB
最終ジャッジ日時 2023-09-19 01:02:07
合計ジャッジ時間 4,326 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,656 KB
testcase_01 AC 77 ms
71,540 KB
testcase_02 AC 78 ms
71,504 KB
testcase_03 AC 77 ms
71,872 KB
testcase_04 AC 78 ms
71,868 KB
testcase_05 AC 77 ms
71,792 KB
testcase_06 AC 78 ms
71,664 KB
testcase_07 AC 77 ms
71,716 KB
testcase_08 AC 78 ms
71,868 KB
testcase_09 AC 77 ms
71,996 KB
testcase_10 AC 78 ms
71,868 KB
testcase_11 AC 79 ms
71,856 KB
testcase_12 AC 79 ms
71,616 KB
testcase_13 AC 79 ms
71,892 KB
testcase_14 AC 97 ms
76,320 KB
testcase_15 AC 197 ms
88,956 KB
testcase_16 AC 132 ms
82,068 KB
testcase_17 AC 118 ms
80,240 KB
testcase_18 AC 94 ms
76,804 KB
testcase_19 AC 87 ms
76,464 KB
testcase_20 AC 77 ms
71,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
import math
N,K = map(int,input().split())
M = max(-(-N//K),math.ceil(N**(1/2)))
HW = [['.']*M for _ in range(M)]

h = []
for i in range(M):
    h.append((0,i))
heapq.heapify(h)
cnt = 0

for i in range(M):
    cnt0 = 0
    while cnt0 < min(K,M):
        a,b = heapq.heappop(h)
        HW[i][b] = '#'
        heapq.heappush(h, (a+1,b))
        cnt0 += 1
        cnt += 1
        if cnt == N:
            break
    if cnt == N:
        break
print(M)
for i in range(M):
    print(*HW[i],sep='')
            
0