結果

問題 No.2178 Payable Magic Items
ユーザー yamakeyamake
提出日時 2023-01-06 21:55:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 4,000 ms
コード長 1,263 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 200,768 KB
実行使用メモリ 6,500 KB
最終ジャッジ日時 2023-08-21 08:15:52
合計ジャッジ時間 3,773 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 10 ms
6,276 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 5 ms
6,320 KB
testcase_06 AC 5 ms
6,280 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 5 ms
6,500 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 62 ms
6,320 KB
testcase_12 AC 63 ms
6,240 KB
testcase_13 AC 70 ms
5,904 KB
testcase_14 AC 68 ms
6,284 KB
testcase_15 AC 68 ms
5,904 KB
testcase_16 AC 67 ms
6,320 KB
testcase_17 AC 30 ms
6,496 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 15 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 51 ms
6,320 KB
testcase_25 AC 18 ms
6,220 KB
testcase_26 AC 18 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<"\n";
using lint = long long;
typedef pair<int,int> P;
const bool debugFlag=true;
const lint linf=1.1e18;const int inf=1.01e9;
constexpr int MOD=1000000007;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }

signed main(){
    int n,k;cin>>n>>k;
    int res=0;
    int m=1;
    rep(i,k)m*=5;
    vector<int> a(m,0);
    rep(i,n){
        string s;cin>>s;
        int x=0;
        for(auto c:s){
            x*=5;
            x+=c-'0';
        }
        a[x]+=1;
    }
    vector<int> dp(m,0);
    for(int status=m-1;status>=0;--status){
        if(dp[status]>0&&a[status]>0){
            ++res;
        }
        if(a[status]>0)dp[status]=1;
        if(dp[status]==0)continue;
        int x=status;
        int base=1;
        rep(_z,k){
            if(x%5>0){
                dp[status-base]=1;
            }
            base*=5;
            x/=5;
        }
    }
    cout<<res<<"\n";
    return 0;
}
0