結果
| 問題 |
No.437 cwwゲーム
|
| ユーザー |
tkmst201
|
| 提出日時 | 2017-05-05 17:13:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,392 bytes |
| コンパイル時間 | 1,309 ms |
| コンパイル使用メモリ | 162,768 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-14 08:43:21 |
| 合計ジャッジ時間 | 3,492 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 9 RE * 4 |
コンパイルメッセージ
main.cpp: In function ‘int dfs(std::vector<int>)’:
main.cpp:40:53: warning: ‘mapos’ may be used uninitialized in this function [-Wmaybe-uninitialized]
40 | done[mapos] = done[j] = done[k] = true;
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
string n;
int dfs(vector<int> v) {
int res;
if (v.size() == 4) {
res = 0;
bool done[13] = {};
REP(i, 4) {
bool ok = false;
for (int j = n.size() - 1; j >= 2; j--) if (!done[j] && n[j] == v[i]) {
for (int k = j - 1; k >= 1; k--) if (!done[k] && n[k] == v[i]) {
int ma = -1, mapos;
REP(l, k) if (n[l] != 0 && n[l] != v[i] && !done[l] && chmax(ma, n[l])) mapos = l;
res += n[mapos] * 100 + n[k] * 10 + n[j];
done[mapos] = done[j] = done[k] = true;
ok = true;
j = k = 0;
}
}
if (!ok) break;
}
}
else {
res = 0;
v.push_back(0);
REP(i, 10) {
v[v.size() - 1] = i;
chmax(res, dfs(v));
}
}
return res;
}
int main() {
cin >> n;
REP(i, n.size()) n[i] -= '0';
cout << dfs(vector<int>()) << endl;
return 0;
}
tkmst201