結果

問題 No.437 cwwゲーム
ユーザー mio_hmio_h
提出日時 2016-10-28 23:15:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,395 bytes
コンパイル時間 1,323 ms
コンパイル使用メモリ 148,172 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 21:59:50
合計ジャッジ時間 2,894 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,384 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,384 KB
testcase_43 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:21: warning: ‘*((void*)& t +17)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             if(t[0] != t[1] && t[1] == t[2]) {

ソースコード

diff #

class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

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


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string cww;
    cin >> cww;
    int n = cww.size();
    vector<int> dp(1 << n, -1);
    int s = (1 << n) - 1;
    dp[s] = 0;
    for(int i : in(s, -1)) if(dp[i] >= 0) {
        if(__builtin_popcount(i) < 3) continue;
        int comb = i;
        do {
            int erased = comb ^ i;
            if(__builtin_popcount(erased) != 3) {
                comb = (comb - 1) & i;
                continue;
            }
            string t = "";
            for(int j : in(n))
              if((1 << j) & erased)
                t += cww[j];
            if(t[0] != t[1] && t[1] == t[2]) {
                int score = (t[0] - '0') * 100 + (t[1] - '0') * 11;
                dp[comb] = max(dp[comb], dp[i] + score);
            }
            comb = (comb - 1) & i;
        } while(comb != i);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}
0