結果

問題 No.241 出席番号(1)
ユーザー kamomekamome
提出日時 2019-07-06 23:39:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,078 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 18,464 KB
最終ジャッジ日時 2024-04-09 05:10:55
合計ジャッジ時間 5,370 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
17,956 KB
testcase_01 AC 33 ms
11,008 KB
testcase_02 AC 33 ms
11,008 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 35 ms
11,136 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 30 ms
11,008 KB
testcase_07 AC 29 ms
11,008 KB
testcase_08 AC 30 ms
10,880 KB
testcase_09 AC 30 ms
10,880 KB
testcase_10 AC 30 ms
10,880 KB
testcase_11 AC 30 ms
10,880 KB
testcase_12 AC 31 ms
10,880 KB
testcase_13 AC 32 ms
11,008 KB
testcase_14 AC 45 ms
11,392 KB
testcase_15 AC 44 ms
11,392 KB
testcase_16 RE -
testcase_17 AC 30 ms
10,880 KB
testcase_18 AC 30 ms
10,880 KB
testcase_19 AC 30 ms
11,008 KB
testcase_20 AC 30 ms
10,880 KB
testcase_21 AC 30 ms
10,880 KB
testcase_22 AC 31 ms
11,008 KB
testcase_23 AC 41 ms
11,264 KB
testcase_24 AC 50 ms
11,520 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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