結果
| 問題 |
No.2178 Payable Magic Items
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-07 00:07:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 4,000 ms |
| コード長 | 724 bytes |
| コンパイル時間 | 1,871 ms |
| コンパイル使用メモリ | 172,264 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-12-14 18:13:41 |
| 合計ジャッジ時間 | 3,544 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#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;
}