結果

問題 No.1587 012 Matrix
ユーザー Shirotsume
提出日時 2021-07-08 23:10:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 46,136 KB
最終ジャッジ日時 2024-07-01 13:10:56
合計ジャッジ時間 17,825 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

import numpy as np

a = np.zeros((n, n))

for i in range(0, n):
    j = 0
    temp = i + 1
    while(temp > 0):
        if temp >= 2:
            a[i][j] = 2
            temp -= 2
        elif temp == 1:
            a[i][j] = 1
            temp -= 1

        j += 1


ansa = set(np.sum(a, axis = 0))
ansb = set(np.sum(a,axis = 1))

if len(ansa | ansb) == 2 * n:
    for i in range(n):
        for j in range(n):
            print(int(a[i][j]), end = ' ')
        print()
else:
    print("No")
0