結果

問題 No.2178 Payable Magic Items
ユーザー t98slidert98slider
提出日時 2023-01-07 00:07:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 4,000 ms
コード長 724 bytes
コンパイル時間 1,661 ms
コンパイル使用メモリ 169,908 KB
実行使用メモリ 7,044 KB
最終ジャッジ日時 2023-08-21 08:26:26
合計ジャッジ時間 3,591 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,136 KB
testcase_01 AC 4 ms
6,288 KB
testcase_02 AC 4 ms
6,432 KB
testcase_03 AC 26 ms
6,252 KB
testcase_04 AC 5 ms
6,352 KB
testcase_05 AC 27 ms
6,192 KB
testcase_06 AC 27 ms
6,352 KB
testcase_07 AC 4 ms
6,156 KB
testcase_08 AC 27 ms
6,244 KB
testcase_09 AC 8 ms
6,196 KB
testcase_10 AC 4 ms
6,152 KB
testcase_11 AC 55 ms
6,952 KB
testcase_12 AC 48 ms
6,944 KB
testcase_13 AC 49 ms
6,944 KB
testcase_14 AC 50 ms
6,948 KB
testcase_15 AC 50 ms
6,920 KB
testcase_16 AC 49 ms
7,044 KB
testcase_17 AC 34 ms
6,516 KB
testcase_18 AC 4 ms
6,156 KB
testcase_19 AC 13 ms
6,156 KB
testcase_20 AC 4 ms
6,148 KB
testcase_21 AC 4 ms
6,184 KB
testcase_22 AC 5 ms
6,420 KB
testcase_23 AC 4 ms
6,248 KB
testcase_24 AC 44 ms
6,948 KB
testcase_25 AC 30 ms
6,248 KB
testcase_26 AC 14 ms
6,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int n, k;
vector<int> a, dp, dp2;
int dfs(int cur){
    if(dp2[cur] != -1)return dp2[cur];
    dp2[cur] = dp[cur];
    for(int i = 0, d = 1; i < k; i++, d *= 5){
        if(cur / d % 5 < 4 && dfs(cur + d)){
            dp2[cur] = 1;
            dp[cur] = 0;
        }
    }
    return dp2[cur];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    a.resize(n, 0);
    dp.resize(25 * 25 * 25 * 25);
    dp2.resize(25 * 25 * 25 * 25, -1);
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        a[i] = stoi(s, nullptr, 5);
        dp[a[i]] = 1;
    }
    dfs(0);
    cout << n - accumulate(dp.begin(), dp.end(), 0) << endl;
}
0