結果

問題 No.334 門松ゲーム
ユーザー 👑 KazunKazun
提出日時 2021-02-10 01:24:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 815 bytes
コンパイル時間 1,660 ms
コンパイル使用メモリ 86,764 KB
実行使用メモリ 77,304 KB
最終ジャッジ日時 2023-09-21 12:46:23
合計ジャッジ時間 3,263 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,372 KB
testcase_01 AC 77 ms
71,300 KB
testcase_02 AC 104 ms
76,692 KB
testcase_03 AC 76 ms
71,300 KB
testcase_04 AC 78 ms
71,260 KB
testcase_05 AC 78 ms
71,356 KB
testcase_06 AC 96 ms
76,600 KB
testcase_07 AC 100 ms
76,396 KB
testcase_08 AC 92 ms
76,224 KB
testcase_09 AC 97 ms
76,468 KB
testcase_10 AC 115 ms
77,304 KB
testcase_11 AC 96 ms
76,464 KB
testcase_12 AC 89 ms
76,356 KB
testcase_13 AC 88 ms
76,364 KB
testcase_14 AC 93 ms
76,552 KB
testcase_15 AC 93 ms
76,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_kadomatsu(x,y,z):
    if x==y or y==z or z==x:
        return False
    return (x>y<z) or (x<y>z)

def bit(i,j,k):
    return (1<<i)+(1<<j)+(1<<k)

def f(S):
    if Flag[S]!=-1:
        return Flag[S]

    for i in range(N):
        for j in range(i+1,N):
            for k in range(j+1,N):
                if bit(i,j,k)&S or (not is_kadomatsu(K[i],K[j],K[k])):
                    continue

                if not f(S|bit(i,j,k)):
                    Flag[S]=1
                    return 1

    Flag[S]=0
    return 0

N=int(input())
K=list(map(int,input().split()))
Flag=[-1]*(1<<N)

if f(0)==0:
    print(-1)
else:
    for i in range(N):
        for j in range(i+1,N):
            for k in range(j+1,N):
                if not Flag[bit(i,j,k)]:
                    print(i,j,k)
                    exit()
0