結果

問題 No.334 門松ゲーム
ユーザー Shirapon_ponShirapon_pon
提出日時 2021-11-03 16:08:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,321 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-21 07:21:44
合計ジャッジ時間 2,100 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 32 ms
11,008 KB
testcase_02 AC 54 ms
10,880 KB
testcase_03 AC 33 ms
10,880 KB
testcase_04 AC 32 ms
11,008 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 46 ms
10,880 KB
testcase_08 AC 38 ms
11,008 KB
testcase_09 AC 38 ms
10,880 KB
testcase_10 AC 65 ms
10,880 KB
testcase_11 AC 39 ms
10,880 KB
testcase_12 AC 229 ms
10,880 KB
testcase_13 WA -
testcase_14 AC 125 ms
10,880 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy

n = int(input())
k = [int(x) for x in input().split()]

def are_kadomatsu(x,y,z):
    if x == y or y == z or z == x:
        return False
    elif x < y < z or x > y > z:
        return False
    return True

def hand(num_list):
    num = len(num_list)
    hand_list = []
    for a in range(num):
        for b in range(a+1, num):
            for c in range(b+1, num):
                if are_kadomatsu(num_list[a], num_list[b], num_list[c]):
                    hand_list.append((a, b, c))
    return hand_list

def game(num_list):
    result = ()
    if hand(num_list):
        for (a,b,c) in hand(num_list):
            ls = copy.copy(num_list)
            ls.pop(a)
            ls.pop(b-1)
            ls.pop(c-2)
            if not hand(ls):
                result = (a,b,c)
                break
            else:
                for (a,b,c) in hand(ls):
                    ls2 = copy.copy(ls)
                    ls2.pop(a)
                    ls2.pop(b-1)
                    ls2.pop(c-2)
                    if not hand(ls2):
                        result = ()
                        break
                    else:
                        result = game(ls2)
    return result

if p:=game(k):
    a, b, c = p
    print(a, b, c)
else:
    print(-1)
0