結果

問題 No.2178 Payable Magic Items
ユーザー そすうぽよそすうぽよ
提出日時 2023-01-06 22:00:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 119 ms / 4,000 ms
コード長 1,330 bytes
コンパイル時間 2,141 ms
コンパイル使用メモリ 204,688 KB
実行使用メモリ 26,436 KB
最終ジャッジ日時 2023-08-21 08:15:48
合計ジャッジ時間 4,702 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 70 ms
6,168 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 69 ms
6,240 KB
testcase_06 AC 70 ms
6,160 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 70 ms
6,108 KB
testcase_09 AC 13 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 118 ms
26,356 KB
testcase_12 AC 116 ms
26,412 KB
testcase_13 AC 118 ms
26,420 KB
testcase_14 AC 119 ms
26,436 KB
testcase_15 AC 119 ms
26,424 KB
testcase_16 AC 118 ms
26,356 KB
testcase_17 AC 84 ms
12,724 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 23 ms
7,752 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 102 ms
20,328 KB
testcase_25 AC 76 ms
8,784 KB
testcase_26 AC 27 ms
9,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <variant>

#define rep2(i, k, n) for (i64 i = (i64)(k); i < (i64)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) begin(x), end(x)
#ifdef ENV_LOCAL
#define dump \
  if (1) cerr
#else
#define dump \
  if (0) cerr
#endif

using namespace std;
using namespace std::string_literals;

using i32 = int32_t;
using i64 = int64_t;
using f64 = double;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;

// using namespace harudake;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n, k;
  cin >> n >> k;
  vi64 vp5(k + 1);
  vp5[0] = 1;
  rep(i, k) vp5[i + 1] = vp5[i] * 5;
  vector s(n, vi64(k));
  vi64 imos(vp5[k]);
  dump << vp5[k] << endl;
  rep(i, n) {
    string str;
    cin >> str;
    i64 idx = 0;
    rep(j, k) {
      s[i][j] = str[j] - '0';
      idx += s[i][j] * vp5[j];
    }
    dump << idx << " ";
    ++imos[idx];
  }
  dump << endl;
  rep(i, k) rep(rj, vp5[k]) {
    i64 j = vp5[k] - 1 - rj;
    i64 rfr = j / vp5[i + 1];
    i64 rto = (j + vp5[i]) / vp5[i + 1];
    if (rfr == rto) {
      imos[j] += imos[j + vp5[i]];
    }
  }
  i64 ans = 0;
  rep(i, n) {
    i64 idx = 0;
    rep(j, k) { idx += s[i][j] * vp5[j]; }
    if (imos[idx] > 1) {
      dump << i << endl;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
0