結果
| 問題 |
No.2178 Payable Magic Items
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2023-01-06 21:56:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 4,000 ms |
| コード長 | 1,220 bytes |
| コンパイル時間 | 1,834 ms |
| コンパイル使用メモリ | 216,428 KB |
| 最終ジャッジ日時 | 2025-02-09 23:53:36 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int pow5[10];
pow5[0] = 1;
rep(i, 9) pow5[i + 1] = pow5[i] * 5;
int n, k;
cin >> n >> k;
VI s(n);
rep(i, n) {
rep(_, k) {
char c;
cin >> c;
s[i] = 5 * s[i] + (c - '0');
}
}
VI d(pow5[k]);
for(int x: s) d[x]++;
rep(z, k) {
rrep(s, pow5[k]) if (s / pow5[z] % 5) {
d[s - pow5[z]] += d[s];
}
}
int ans = 0;
for(int x: s) ans += d[x] > 1;
cout << ans << '\n';
}
Kude