結果

問題 No.437 cwwゲーム
コンテスト
ユーザー mkawa2
提出日時 2020-08-01 22:38:31
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 541 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 466 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-03-30 03:15:15
合計ジャッジ時間 5,760 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

t = input()
n = len(t)
aa = [int(c) for c in t]

def dfs(i, s):
    if i > n - 3: return 0
    if s >> i & 1 or aa[i]==0: return dfs(i + 1, s)
    res = dfs(i + 1, s)
    for j in range(i + 1, n - 1):
        if s >> j & 1: continue
        if aa[i]==aa[j]:continue
        for k in range(j + 1, n):
            if s >> k & 1: continue
            if aa[j] == aa[k]:
                ns = s | 1 << j | 1 << k
                cur = 100 * aa[i] + 11 * aa[j] + dfs(i + 1, ns)
                res = max(res, cur)
    return res

print(dfs(0, 0))
0