結果

問題 No.2263 Perms
ユーザー titia
提出日時 2023-04-08 01:01:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-02 21:56:01
合計ジャッジ時間 7,335 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from operator import itemgetter

N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]

B=[]

for i in range(N):
    X=A[i]
    Y=[[X[j],j+1] for j in range(N)]

    Y.sort(key=itemgetter(0),reverse=True)
    B.append(Y)

ANS=[]

for tests in range(M):
    X=[]*N
    USE=[0]*(N+1)

    for i in range(N):
        for j in range(N):
            w,ind=B[i][j]

            if w>0 and USE[ind]==0:
                X.append(ind)
                USE[ind]=1
                B[i][j][0]-=1
                break

    if len(X)==N:
        ANS.append(X)
    else:
        print(-1)
        exit()

for ans in ANS:
    print(*ans)
                
                
        

    
    
    

0