結果

問題 No.437 cwwゲーム
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-04-07 01:19:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,354 bytes
コンパイル時間 1,115 ms
コンパイル使用メモリ 92,796 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 13:19:16
合計ジャッジ時間 2,097 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

string S;
int x;

void print() {
    for ( int i = S.length()-1; i >= 0; i-- ) {
        cout << ( x&(1<<i) ? 1 : 0 );
    }
    cout << endl;
}

int func( int score ) {
    // print();
    int ret = score;

    vector<int> A;
    for ( int i = S.length()-1; i >= 0; i-- ) {
        if ( x&(1<<i) ) { A.push_back(i) ; }
    }

    for ( int a = 0; a < A.size(); a++ ) {
    for ( int b = a+1; b < A.size(); b++ ) {
    for ( int c = b+1; c < A.size(); c++ ) {
        int y = x;
        int sa = S.length()-1-A[a];
        int sb = S.length()-1-A[b];
        int sc = S.length()-1-A[c];
        if ( S[sa] != '0' && S[sa] != S[sb] && S[sb] == S[sc] ) {
            x = x^(1<<A[a])^(1<<A[b])^(1<<A[c]);
            string s = "";
            s += S[sa];
            s += S[sb];
            s += S[sc];
            // cout << s << endl;
            ret = max( ret, func( score+stoi(s) ) );
        }
        x = y;
    }
    }
    }

    return ret;
}

int main() {
    
    cin >> S;
    x = ( 1 << S.length() )-1;    

    cout << func(0) << endl;

    return 0;
}
0