結果

問題 No.241 出席番号(1)
ユーザー kamome
提出日時 2019-07-06 23:37:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 23,040 KB
最終ジャッジ日時 2024-10-01 15:25:07
合計ジャッジ時間 8,221 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 3 WA * 18 RE * 1 OLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3
import copy
N=int(input())
unfav=[]
ok=[]
for i in range(N):
    uf=int(input())
    unfav.append(uf)
    oklist=list(range(N))
    try:
        oklist.remove(uf)
    except ValueError:
        pass
    ok.append(oklist)

def regress(l,_n=None,num=None): # n はn人目、 numは確定番号
    LL=copy.deepcopy(l)
    if _n is None:
        for i in LL[0]:
            L=regress(LL,0,i)
            if L:
                return L
        if L is None:
            return None

    if num in LL[_n] and (LL[_n] is not None):
        LL[_n]=[num]
        for i in range(N):
            if i==_n:
                continue
            if num in LL[i]:
                LL[i].remove(num)
                #print(LL)
            print(LL)
        if _n==N-1:
            return LL
    else:
        return None

    for j in LL[_n+1]:
        res=regress(LL,_n+1,j)
        if res:
            return res


ok_regress=regress(ok)
if ok_regress is None:
    print("-1")
else:
    for i in range(N):
        print(int(ok_regress[i][0]))
    
#print(ok_regress)
     
0