結果

問題 No.1087 転倒数の転倒数
ユーザー tyawanmusityawanmusi
提出日時 2020-05-19 15:33:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 522 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 97,920 KB
最終ジャッジ日時 2024-04-24 19:48:20
合計ジャッジ時間 16,721 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,624 KB
testcase_01 AC 26 ms
10,624 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 26 ms
10,624 KB
testcase_06 AC 28 ms
10,880 KB
testcase_07 AC 28 ms
10,624 KB
testcase_08 AC 27 ms
10,624 KB
testcase_09 AC 28 ms
10,624 KB
testcase_10 AC 27 ms
10,624 KB
testcase_11 AC 26 ms
10,752 KB
testcase_12 WA -
testcase_13 AC 26 ms
10,752 KB
testcase_14 AC 31 ms
10,880 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 478 ms
18,816 KB
testcase_18 AC 27 ms
10,624 KB
testcase_19 AC 26 ms
10,752 KB
testcase_20 AC 31 ms
11,008 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 272 ms
15,104 KB
testcase_30 AC 147 ms
12,928 KB
testcase_31 AC 371 ms
16,768 KB
testcase_32 AC 358 ms
16,640 KB
testcase_33 AC 228 ms
14,592 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# writer解リベンジ
n, k = map(int, input().split())
if k > n*(n-1):
    print("No")
    exit()
if k == 1:
    print("No")
    exit()
ans = [n*[0] for _ in range(n)]
if k >= 2 * (n - 1):
    q = []
    for i in range(n):
        ans[i][i] = 1
    for i in range(n-2, 0, -1):
        for j in range(i-1, -1, -1):
            q.append((i, j))
            q.append((j, i))
    for i, j in q:
        ans[i][j] = 1
elif k > 1:
    ans[n - 1 - k // 2][n - 1 - (k // 2 + k % 2)] = 1
print("Yes")
for i in ans:
    print(*i)
0