結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-28 22:38:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,765 bytes |
| コンパイル時間 | 957 ms |
| コンパイル使用メモリ | 101,780 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 08:22:16 |
| 合計ジャッジ時間 | 2,183 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
if(p) cout << fixed << setprecision(p) << a << "\n";
else cout << a << "\n";
}
// end of template
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
// source code
string s;
cin >> s;
queue<pair<string, int>> q;
q.push(mp(s, 0));
int ret = 0;
while(!q.empty()){
string t = q.front().first;
int u = q.front().second;
q.pop();
bool iscww = false;
rep(i, t.size()) rep(j, i + 1, t.size()) rep(k, j + 1, t.size()){
if(t[i] != '0' && t[j] == t[k] && t[i] != t[j]){
iscww = true;
string v = "";
rep(l, t.size()){
if(l != i && l != j && l != k){
v += t[l];
}
}
q.push(mp(v, u + 100 * (t[i] - '0') + 10 * (t[j] - '0') + t[k] - '0'));
// cout << t << ", " << u << ": " << v << ", " << u + 100 * (t[i] - '0') + 10 * (t[j] - '0') + t[k] - '0' << endl;
}
}
if(!iscww) ret = max(ret, u);
}
output(ret);
return 0;
}