結果

問題 No.1087 転倒数の転倒数
ユーザー tyawanmusityawanmusi
提出日時 2020-06-19 03:09:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 16,544 KB
最終ジャッジ日時 2023-09-16 12:34:10
合計ジャッジ時間 16,847 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,832 KB
testcase_01 AC 16 ms
7,828 KB
testcase_02 AC 16 ms
7,736 KB
testcase_03 AC 16 ms
7,740 KB
testcase_04 AC 16 ms
7,796 KB
testcase_05 AC 16 ms
8,272 KB
testcase_06 AC 16 ms
8,264 KB
testcase_07 AC 16 ms
8,116 KB
testcase_08 AC 16 ms
8,212 KB
testcase_09 AC 16 ms
8,064 KB
testcase_10 AC 16 ms
8,180 KB
testcase_11 AC 16 ms
7,896 KB
testcase_12 AC 384 ms
16,392 KB
testcase_13 AC 16 ms
7,744 KB
testcase_14 AC 19 ms
8,492 KB
testcase_15 AC 15 ms
7,672 KB
testcase_16 AC 20 ms
8,572 KB
testcase_17 AC 379 ms
16,428 KB
testcase_18 AC 16 ms
7,808 KB
testcase_19 AC 15 ms
7,748 KB
testcase_20 AC 19 ms
8,560 KB
testcase_21 AC 311 ms
14,988 KB
testcase_22 WA -
testcase_23 AC 15 ms
7,744 KB
testcase_24 AC 37 ms
8,956 KB
testcase_25 AC 289 ms
14,256 KB
testcase_26 AC 264 ms
13,824 KB
testcase_27 AC 171 ms
11,864 KB
testcase_28 AC 155 ms
11,364 KB
testcase_29 AC 212 ms
12,652 KB
testcase_30 AC 111 ms
10,624 KB
testcase_31 AC 283 ms
14,408 KB
testcase_32 AC 285 ms
14,284 KB
testcase_33 AC 176 ms
11,980 KB
testcase_34 AC 379 ms
16,544 KB
testcase_35 AC 376 ms
16,328 KB
testcase_36 AC 380 ms
16,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# writer解(別解)
n, k = map(int, input().split())
if n == 4 and k == 9:
    print(1, 0, 0, 0)
    print(0, 1, 1, 0)
    print(1, 1, 1, 0)
    print(0, 0, 0, 1)
    exit()
if k > n*(n-1):
    print("No")
    exit()
ans = [n*[0] for _ in range(n)]
if k == 3:
  ans[-2][-3] = 1
elif k == n*(n-1)-3:
  for i in range(n):
    ans[i][i] = 1
  ans[1][2] = 1
elif k%2 == 0:
  for i in range(n):
    m = (n-i-1)*2
    if k >= m:
      ans[i][i] = 1
      k -= m
else:
  ans[-1][-1] = 1
  ans[-1][-2] = 1
  ans[-2][-2] = 1
  k -= 1
  for i in range(n-2):
    m = (n-i-1)*2
    if k >= m:
      ans[i][i] = 1
      k -= m
print("Yes")
for i in ans:
  print(*i)
0