結果

問題 No.2178 Payable Magic Items
ユーザー 沙耶花沙耶花
提出日時 2023-01-06 21:45:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 4,000 ms
コード長 792 bytes
コンパイル時間 4,236 ms
コンパイル使用メモリ 259,028 KB
実行使用メモリ 7,864 KB
最終ジャッジ日時 2023-08-21 08:13:41
合計ジャッジ時間 6,103 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 26 ms
7,720 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 26 ms
7,580 KB
testcase_06 AC 26 ms
7,720 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 27 ms
7,716 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 79 ms
7,660 KB
testcase_12 AC 79 ms
7,596 KB
testcase_13 AC 80 ms
7,584 KB
testcase_14 AC 82 ms
7,864 KB
testcase_15 AC 82 ms
7,564 KB
testcase_16 AC 82 ms
7,532 KB
testcase_17 AC 45 ms
7,584 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 17 ms
4,376 KB
testcase_20 AC 2 ms
4,376 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 65 ms
7,716 KB
testcase_25 AC 34 ms
7,516 KB
testcase_26 AC 22 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 2000000000000000005



int main(){
	
	int N,K;
	cin>>N>>K;
	
	int cur = 1;
	rep(i,K)cur *= 5;
	vector a(cur,0);
	
	rep(i,N){
		string t;
		cin>>t;
		int v = 0;
		int cc = 1;
		rep(j,K){
			v += cc * (t[j]-'0');
			cc *= 5;
		}
		a[v] ++;
	}
	vector dp = a;
	cur = 1;
	rep(i,K){
		vector ndp(dp.size(),0);
		rep(j,dp.size()){
			int jj = j/cur % 5;
			for(int k=jj;k<=4;k++){
				ndp[j] += dp[j + cur * (k-jj)];
			}
		}
		swap(dp,ndp);
		cur *= 5;
	}
	
	int ans = 0;
	rep(i,a.size()){
		if(a[i]==0)continue;
		if(dp[i]!=1)ans++;
	}
	cout<<ans<<endl;
			
	
    return 0;
}
0