結果

問題 No.437 cwwゲーム
ユーザー 0w1
提出日時 2016-11-26 14:01:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 167,944 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 08:40:36
合計ジャッジ時間 2,672 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int cww( int a, int b, int c ){
  return a != '0' and a != b and b == c;
}

int dfs( const string &s ){
  int res = 0;
  for( int i = 0; i < s.size(); ++i )
    for( int j = i + 1; j < s.size(); ++j )
      for( int k = j + 1; k < s.size(); ++k )
        if( cww( s[ i ], s[ j ], s[ k ] ) ){
          string t = s;
          t.erase( t.begin() + k );
          t.erase( t.begin() + j );
          t.erase( t.begin() + i );
          res = max( res, ( s[ i ] - '0' ) * 100 + ( s[ j ] - '0' ) * 10 + ( s[ k ] - '0' ) + dfs( t ) );
        }
  return res;
}

signed main(){
  string S; cin >> S;
  cout << dfs( S ) << endl;
  return 0;
}
0