結果
問題 | No.437 cwwゲーム |
ユーザー |
![]() |
提出日時 | 2017-07-10 12:56:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 556 bytes |
コンパイル時間 | 1,575 ms |
コンパイル使用メモリ | 167,852 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 08:43:54 |
合計ジャッジ時間 | 2,848 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include <bits/stdc++.h>#define REP(i,n,N) for(int i=(n);i<(int) N;i++)#define p(s) cout<<(s)<<endlusing namespace std;string s;int dp[1 << 13];int main() {cin>>s;int n=s.size();REP(mask, 0, 1<<n) {REP(i, 0, n) {REP(j,i+1,n){REP(k,j+1,n){if (!(mask & (1<<i))&&!(mask & (1<<j))&&!(mask & (1<<k))&&s[i]!='0'&&s[i]!=s[j]&&s[j]==s[k]){dp[mask | (1 << i)|(1 << j)|(1 << k)] = max(dp[mask | (1 << i)|(1 << j)|(1 << k)],dp[mask]+100*(s[i]-'0')+10*(s[j]-'0')+s[k]-'0');}}}}}p(dp[(1<<n)-1]);return 0;}