結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-29 00:18:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 743 bytes |
| コンパイル時間 | 106 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 12,032 KB |
| 最終ジャッジ日時 | 2024-10-12 08:27:03 |
| 合計ジャッジ時間 | 2,896 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
from itertools import combinations
n = input()
def is_cww(i, j, k):
return i != '0' and i != j and j == k
max_score = 0
stack = [(0, n)]
while len(stack) > 0:
score, ns = stack[0]
del stack[0]
if len(ns) < 3:
if max_score < score:
max_score = score
continue
num_cww = 0
for i, j, k in combinations(range(len(ns)), 3):
c, w1, w2 = ns[i], ns[j], ns[k]
if is_cww(c, w1, w2):
num_cww += 1
cww = int(c + w1 + w2)
nx = ''.join([ns[l] for l in range(len(ns)) if l != i and l != j and l != k])
stack.append((score + cww, nx))
if num_cww == 0:
if max_score < score:
max_score = score
print(max_score)