結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
sorafire
|
| 提出日時 | 2020-06-20 17:32:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 776 bytes |
| コンパイル時間 | 1,468 ms |
| コンパイル使用メモリ | 167,700 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 17:28:06 |
| 合計ジャッジ時間 | 2,783 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int ans=0;
string s;
bool used[15];
void dfs(int i, int tmx){
if(i>=s.size()-1){
ans=max(ans,tmx);
return;
}
for(int k=i+1;k<s.size();k++){
if(s[i]!=s[k] || used[i] || used[k])continue;
for(int j=0;j<i;j++){
if(!used[j] && s[i]!=s[j] && s[j] != '0') {
used[i]=used[k]=used[j]=1;
string ns="";ns+=s[j];ns+=s[i];ns+=s[i];
// cout<<tmx+stoi(ns)<<':'<<stoi(ns)<<endl;
dfs(i + 1, tmx+stoi(ns));
used[i]=used[k]=used[j]=0;
}
}
}
dfs(i + 1, tmx);
}
int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
cin>>s;
dfs(0,0);
cout<<ans<<endl;
return 0;
}
sorafire