結果

問題 No.3721 Absurd Basic Constructive
コンテスト
ユーザー yas_yasyu
提出日時 2026-09-19 20:29:08
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 568 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 70 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 113,548 KB
最終ジャッジ日時 2026-09-19 20:29:18
合計ジャッジ時間 7,175 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque

N, K = map(int, input().split())

idx = 0
order = deque()
for j_start in range(N * 2):
    i = 0
    j = j_start
    while idx < N * N:
        if 0 <= i < N and 0 <= j < N:
            order.append((i, j))
            idx += 1
        i += 1
        j -= 1
        if i >= N or j < 0:
            break

ans = [[-1] * N for _ in range(N)]
idx = N * N
for _ in range(K):
    i, j = order.popleft()
    ans[i][j] = idx
    idx -= 1

idx = 1
while order:
    i, j = order.pop()
    ans[i][j] = idx
    idx += 1

for a in ans:
    print(a)
0