結果
問題 | No.437 cwwゲーム |
ユーザー |
|
提出日時 | 2016-10-29 19:08:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 1,397 bytes |
コンパイル時間 | 1,520 ms |
コンパイル使用メモリ | 168,500 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 08:32:32 |
合計ジャッジ時間 | 3,337 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i,a,b) for(int i=a;i<b;++i) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define ALL(a) begin(a),end(a) #define ifnot(a) if(not (a)) #define dump(x) cerr << #x << " = " << (x) << endl using namespace std; // #define int ll #ifdef _MSC_VER const bool test = true; #else const bool test = false; #endif int dx[] = { 0,1,0,-1 }; int dy[] = { 1,0,-1,0 }; #define INF (1 << 28) ull mod = (int)1e9 + 7; //..................... const int MAX = (int)1e5 + 5; string s; int dfs(int depth) { int max_score = 0; rep(i, s.size()) { if (isalpha(s[i])) continue; if (s[i] == '0') continue; REP(j, i + 1, s.size()) { if (isalpha(s[j])) continue; REP(k, j + 1, s.size()) { if (isalpha(s[k])) continue; if (s[i] == s[j]) continue; if (s[j] != s[k]) continue; int cur_score = (s[i] - '0') * 100 + (s[j] - '0') * 10 + (s[k] - '0') * 1; string buf = s; s[i] = s[j] = s[k] = 'a' + depth; dump(cur_score); dump(s); cerr << endl; int tmp = dfs(depth + 1) + cur_score; if (tmp > max_score) max_score = tmp; s = buf; } } // dump(i); // dump(max_score); // cerr << endl; } return max_score; } signed main() { cin >> s; dump(s); cout << dfs(0) << endl; return 0; }