結果

問題 No.437 cwwゲーム
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-12 23:55:06
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 11,912 KB
実行使用メモリ 10,200 KB
最終ジャッジ日時 2023-10-20 02:49:04
合計ジャッジ時間 2,946 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,112 KB
testcase_01 AC 30 ms
9,996 KB
testcase_02 AC 30 ms
10,116 KB
testcase_03 AC 29 ms
10,112 KB
testcase_04 AC 29 ms
10,112 KB
testcase_05 AC 30 ms
10,112 KB
testcase_06 AC 31 ms
10,116 KB
testcase_07 AC 40 ms
10,192 KB
testcase_08 AC 34 ms
10,128 KB
testcase_09 AC 39 ms
10,192 KB
testcase_10 AC 38 ms
10,176 KB
testcase_11 AC 30 ms
9,996 KB
testcase_12 AC 32 ms
10,112 KB
testcase_13 AC 32 ms
10,116 KB
testcase_14 AC 32 ms
10,116 KB
testcase_15 AC 41 ms
10,200 KB
testcase_16 AC 31 ms
10,112 KB
testcase_17 AC 31 ms
10,112 KB
testcase_18 AC 32 ms
10,112 KB
testcase_19 AC 30 ms
10,112 KB
testcase_20 AC 31 ms
10,112 KB
testcase_21 AC 30 ms
10,112 KB
testcase_22 AC 30 ms
10,112 KB
testcase_23 AC 30 ms
10,112 KB
testcase_24 AC 30 ms
10,112 KB
testcase_25 AC 30 ms
10,112 KB
testcase_26 AC 30 ms
10,112 KB
testcase_27 AC 30 ms
9,996 KB
testcase_28 AC 30 ms
10,112 KB
testcase_29 AC 30 ms
9,996 KB
testcase_30 AC 29 ms
9,996 KB
testcase_31 AC 29 ms
9,996 KB
testcase_32 AC 30 ms
9,996 KB
testcase_33 AC 30 ms
10,112 KB
testcase_34 AC 30 ms
10,112 KB
testcase_35 AC 30 ms
10,112 KB
testcase_36 AC 29 ms
9,996 KB
testcase_37 AC 29 ms
9,996 KB
testcase_38 AC 29 ms
10,112 KB
testcase_39 AC 30 ms
9,996 KB
testcase_40 AC 30 ms
10,112 KB
testcase_41 AC 30 ms
10,112 KB
testcase_42 AC 30 ms
10,112 KB
testcase_43 AC 29 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = list(input().rstrip())
N = len(S)
if N < 3:
    print(0)
    exit()

ans = 0


@lru_cache(maxsize=None)
def rec(score, bit):
    global ans
    if score > ans:
        ans = score
    for i in range(N-2):
        if (bit >> i) & 1:
            continue
        a = S[i]
        for j in range(i + 1, N - 1):
            if (bit >> j) & 1:
                continue
            b = S[j]
            for k in range(j + 1, N):
                if (bit >> k) & 1:
                    continue
                c = S[k]
                if a != "0" and b == c and a != b:
                    bit_next = bit
                    bit_next ^= (1 << i)
                    bit_next ^= (1 << j)
                    bit_next ^= (1 << k)
                    rec(score + int(a+b+c), bit_next)


rec(0, 0)
print(ans)
0