結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
HO_RI1991
|
| 提出日時 | 2016-10-28 22:48:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,502 bytes |
| コンパイル時間 | 1,432 ms |
| コンパイル使用メモリ | 135,136 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 08:23:43 |
| 合計ジャッジ時間 | 2,676 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#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;
}
HO_RI1991