結果
問題 |
No.437 cwwゲーム
|
ユーザー |
![]() |
提出日時 | 2016-10-25 16:03:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 956 bytes |
コンパイル時間 | 1,683 ms |
コンパイル使用メモリ | 172,656 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 08:20:17 |
合計ジャッジ時間 | 2,802 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) int n; vector<int> s; int cww(int a, int b, int c) { if (a != 0 && a != b && b == c) { return 100 * a + 10 * b + c; } return -1; } int dfs(vector<bool> used) { int ret = 0; rep(i, n) { rep2(j, i + 1, n) { rep2(k, j + 1, n) { if (used[i] || used[j] || used[k]) continue; int x = cww(s[i], s[j], s[k]); if (x != -1) { vector<bool> nxused = used; nxused[i] = nxused[j] = nxused[k] = true; ret = max(ret, dfs(nxused) + x); } } } } return ret; } int main() { string tmp; cin >> tmp; n = tmp.size(); s.resize(n); rep(i, n) { s[i] = tmp[i] - '0'; } cout << dfs(vector<bool>(n)) << endl; }