結果
| 問題 |
No.437 cwwゲーム
|
| ユーザー |
sorafire
|
| 提出日時 | 2020-06-20 17:31:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 761 bytes |
| コンパイル時間 | 1,480 ms |
| コンパイル使用メモリ | 169,112 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 17:27:47 |
| 合計ジャッジ時間 | 2,870 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 WA * 1 |
ソースコード
#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]) {
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