結果
問題 | No.437 cwwゲーム |
ユーザー |
![]() |
提出日時 | 2016-11-11 09:52:51 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 385 ms / 2,000 ms |
コード長 | 482 bytes |
コンパイル時間 | 262 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-10-12 08:39:05 |
合計ジャッジ時間 | 4,732 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
N = input()M = len(N)dp = [0] * (1<<M)def isCww(i,j,k):return N[i] != '0' and N[i] != N[j] and N[j] == N[k]for s in range(1<<M):for i in range(M):if (s>>i)&1==1:continuefor j in range(i + 1,M):if (s>>j)&1==1:continuefor k in range(j + 1,M):if (s>>k)&1==1:continueif not isCww(i,j,k):continuenext = (1<<i)|(1<<j)|(1<<k)next |= sv = int(N[i]+N[j]+N[k])dp[next] = max(dp[next],dp[s] + v)print(max(dp))