結果

問題 No.2178 Payable Magic Items
ユーザー KudeKude
提出日時 2023-01-06 21:56:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 4,000 ms
コード長 1,220 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 224,316 KB
実行使用メモリ 5,428 KB
最終ジャッジ日時 2023-08-21 08:14:00
合計ジャッジ時間 3,777 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 13 ms
4,696 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 14 ms
4,588 KB
testcase_06 AC 13 ms
4,652 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 13 ms
4,648 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 32 ms
5,356 KB
testcase_12 AC 32 ms
5,352 KB
testcase_13 AC 32 ms
5,388 KB
testcase_14 AC 33 ms
5,428 KB
testcase_15 AC 32 ms
5,424 KB
testcase_16 AC 32 ms
5,364 KB
testcase_17 AC 20 ms
4,840 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 8 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 26 ms
5,120 KB
testcase_25 AC 16 ms
4,560 KB
testcase_26 AC 9 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0