結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2016-11-02 01:16:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 760 bytes |
| コンパイル時間 | 756 ms |
| コンパイル使用メモリ | 74,188 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 08:35:41 |
| 合計ジャッジ時間 | 1,926 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <iostream>
#include <sstream>
#include <map>
#include <algorithm>
using namespace std;
map<string, int> m;
int dfs(string s) {
if (m.find(s) == m.end()) {
int x = 0;
for (int i = 0; i < (int)s.length() - 2; ++i) {
if (s[i] != '0') {
for (int j = i + 1; j < (int)s.length() - 1; ++j) {
if (s[i] != s[j]) {
for (int k = j + 1; k < (int)s.length(); ++k) {
if (s[j] == s[k]) {
string r = s.substr(i + 1, j - i - 1) + s.substr(j + 1, k - j - 1) + s.substr(k + 1);
x = max(x, (s[i] - '0') * 100 + (s[j] - '0') * 11 + dfs(r));
}
}
}
}
}
}
m[s] = x;
}
return m[s];
}
int main(int argc, char *argv[]) {
std::string s;
std::cin >> s;
std::cout << dfs(s) << std::endl;
return 0;
}
hotpepsi