結果

問題 No.437 cwwゲーム
ユーザー matsukin1111
提出日時 2019-04-03 00:05:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,290 bytes
コンパイル時間 1,462 ms
コンパイル使用メモリ 105,280 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-14 15:06:34
合計ジャッジ時間 2,477 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };

string n;
map<set<int>, int>m;

int dfs(set<int>s,int sum) {
	if (m.find(s) != m.end())return m[s];

	int ans = sum;
	rep(i, 0, n.size())rep(j, i + 1, n.size())rep(k, j + 1, n.size()) {
		if (n[i] != '0' && n[i] != n[j] && n[j] == n[k]) {
			if (s.count(i) == 0 && s.count(j) == 0 && s.count(k) == 0) {
				int num = 100 * (n[i] - '0') + 10 * (n[j] - '0') + (n[k] - '0');
				set<int>tmp = s;
				tmp.insert(i), tmp.insert(j), tmp.insert(k);
				ans = max(dfs(tmp,sum+num),ans);
			}
		}
	}
	return m[s] = ans;
}

int main(){
	cin >> n;
	set<int>s;
	cout << dfs(s, 0) << endl;
	return 0;
}
0