結果
問題 |
No.437 cwwゲーム
|
ユーザー |
![]() |
提出日時 | 2016-11-16 21:47:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 930 bytes |
コンパイル時間 | 1,858 ms |
コンパイル使用メモリ | 166,568 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 02:30:52 |
合計ジャッジ時間 | 3,115 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 1 |
ソースコード
#include <bits/stdc++.h> int xs[12]; int dfs(bool checked[12]) { int res = 0; for(int i = 0; i < 12; ++i) { if( checked[i] ) continue; checked[i] = true; for(int j = i + 1; j < 12; ++j) { if( checked[j] ) continue; if( xs[i] == xs[j] ) continue; checked[j] = true; for(int k = j + 1; k < 12; ++k) { if( checked[k] ) continue; if( xs[j] != xs[k] ) continue; checked[k] = true; int x = 100 * xs[i] + 10 * xs[j] + xs[k]; int x2 = x + dfs(checked); res = std::max(x2, res); checked[k] = false; } checked[j] = false; } checked[i] = false; } return res; } int main() { std::string str; std::cin >> str; bool checked[12] = {}; for(int i = (int)str.size(); i < 12; ++i) checked[i] = true; for(int i = 0; i < (int)str.size(); ++i) xs[i] = str[i] - '0'; printf("%d\n", dfs(checked)); return 0; }