結果

問題 No.2263 Perms
ユーザー titiatitia
提出日時 2023-04-08 01:05:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 908 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-12 10:17:36
合計ジャッジ時間 4,656 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 24 ms
10,880 KB
testcase_02 AC 25 ms
10,752 KB
testcase_03 AC 25 ms
10,752 KB
testcase_04 AC 24 ms
10,880 KB
testcase_05 AC 25 ms
10,752 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 35 ms
11,136 KB
testcase_09 WA -
testcase_10 AC 43 ms
10,880 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 28 ms
10,880 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
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 WA -
testcase_30 WA -
testcase_31 AC 26 ms
10,752 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 25 ms
10,880 KB
testcase_35 AC 25 ms
10,880 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 25 ms
10,880 KB
testcase_40 AC 25 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

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

        B[i].sort(key=itemgetter(0),reverse=True)

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

for i in range(N):
    for j in range(N):
        if B[i][j][0]>0:
            print(-1)
            exit()

for ans in ANS:
    print(*ans)
                
                
        

    
    
    

0