結果

問題 No.437 cwwゲーム
ユーザー HO_RI1991HO_RI1991
提出日時 2016-10-28 22:48:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,502 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 133,800 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 12:59:23
合計ジャッジ時間 2,416 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>

#include<typeinfo>
#include<numeric>
#include<complex>
#include<memory>
#include<fstream>
#include<chrono>
#include<random>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main(){
	string str;
	cin>>str;

	long long ans=0;
	queue<tuple<int,long long,vector<bool>>> Q;
	Q.push(make_tuple(0,0,vector<bool>(str.size(),false)));
	while(!Q.empty()){
		auto now=Q.front();
		Q.pop();
		int index=get<0>(now);
		long long score=get<1>(now);
		vector<bool> vec=get<2>(now);

		if(str.size()<3 || index>(str.size()-3)){
			ans=max(ans,score);
		}
		else{
			if(!vec[index] && str[index]!='0'){
				for(int i=index+1;i<str.size();++i){
					for(int j=i+1;j<str.size();++j){
						if(str[i]==str[j] && str[index]!=str[i] && !vec[i] && !vec[j]){
							long long tmp=(str[index]-'0')*100+(str[i]-'0')*10+(str[j]-'0');
							vector<bool> a=vec;
							a[index]=true;
							a[i]=true;
							a[j]=true;
							Q.push(make_tuple(index+1,score+tmp,a));
						}
					}
				}
			}
			Q.push(make_tuple(index+1,score,vec));
		}
	}
	cout<<ans<<endl;
	//system("pause");
	return 0;
}
0