結果
| 問題 |
No.2178 Payable Magic Items
|
| コンテスト | |
| ユーザー |
yamake
|
| 提出日時 | 2023-01-06 21:55:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 4,000 ms |
| コード長 | 1,263 bytes |
| コンパイル時間 | 2,148 ms |
| コンパイル使用メモリ | 195,188 KB |
| 最終ジャッジ日時 | 2025-02-09 23:53:01 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#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;
}
yamake