結果
問題 | No.437 cwwゲーム |
ユーザー |
![]() |
提出日時 | 2016-10-29 00:36:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,942 bytes |
コンパイル時間 | 808 ms |
コンパイル使用メモリ | 75,764 KB |
実行使用メモリ | 6,816 KB |
最終ジャッジ日時 | 2024-10-12 08:27:06 |
合計ジャッジ時間 | 1,918 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 1 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <unordered_map>#include <unordered_set>#define REP(i,n) for(int i=0;i<n;++i)#define ALL(a) (a).begin(),(a).end()typedef long long int LLI;typedef unsigned long long int ULLI;using namespace std;string replace5126(string str, string old_s, string new_s) {int i;if (old_s == "") { return str; }while ((i = str.find(old_s)) > -1) { str.replace(i, old_s.size(), new_s); }return str;}int count5126(string str, string a) {int i = 0, cnt = 0;if (a == "") { return -1; }while ((i = str.find(a, i)) > -1) { ++cnt; i += a.size(); }return cnt;}vector<string> split5126(string str, string sep) {int s = 0, p = 0;vector<string> v;if (sep == "") {v.push_back(str);return v;}while ((p = str.find(sep, s)) > -1) {v.push_back(str.substr(s, p - s));s = p + sep.size();}v.push_back(str.substr(s, str.size()));return v;}string slice5126(string str, int a, int b) {int s = a < 0 ? str.size() + a : a;int e = b < 0 ? str.size() + b : b;e = b == 0 ? str.size() : e;return str.substr(s, (s > e ? s : e) - s);}string strdel(string s, int t) {string r = "";string ts = to_string(t);int c = 0;for (auto i : s) {if (c < 3 && i == ts[c]) {++c;} else {r += i;}}return c < 3 ? "e" : r;}LLI solve(string s, LLI n) {LLI r = n;string a;if (s.size() < 3) { return r; }for (int x = 1; x < 10; ++x) {for (int y = 0; y < 10; ++y) {a = strdel(s, (x * 100 + y * 10 + y));if (x != y && a != "e") {r = max(r, solve(a, n + (x * 100 + y * 10 + y)));}}}return r;}int main() {LLI n;cin >> n;cout << solve(to_string(n), 0) << endl;return 0;}