結果
問題 | No.437 cwwゲーム |
ユーザー |
![]() |
提出日時 | 2016-10-29 05:30:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 620 bytes |
コンパイル時間 | 550 ms |
コンパイル使用メモリ | 67,584 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 08:29:41 |
合計ジャッジ時間 | 1,611 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include <iostream> #include <algorithm> #include <string> using namespace std; int memo[1<<13]; int func(const string& s, int mask) { int& res=memo[mask]; if (~res) return res; int n=s.size(); res=0; for(int i=0; i<n; ++i) if (!(mask&1<<i) and s[i]!='0') for(int j=i+1; j<n; ++j) if (!(mask&1<<j) and s[i]!=s[j]) for(int k=j+1; k<n; ++k) if (!(mask&1<<k) and s[j]==s[k]) res=max(res, func(s, mask|1<<i|1<<j|1<<k)+100*(s[i]-'0')+11*(s[j]-'0')); return res; } int main() { string s; cin>>s; fill(memo, memo+(1<<13), -1); cout<<func(s, 0)<<endl; }