結果

問題 No.1783 Remix Sum
ユーザー NyaanNyaan
提出日時 2021-10-22 23:39:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,080 bytes
コンパイル時間 1,391 ms
コンパイル使用メモリ 93,204 KB
最終ジャッジ日時 2025-01-25 04:30:05
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 2
other AC * 30 RE * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

long long ten[] = {1, 10, 100, 1000, 10000, 100000, 1000000};
long long TEN(int n) { return ten[n]; }

int main() {
  long long n, k, m, t;
  cin >> n >> k >> m >> t;
  // assert(10 <= m and m <= 15);
  vector<int> a(n);
  for (auto& x : a) {
    cin >> x;
    // assert(0 <= x and x < TEN(k));
  }
  if (log(n) * m > 20) exit(1);

  auto sm = [&](int i, int j) {
    int res = 0;
    for (int d = 0; d < k; d++) {
      if (d < t) {
        if (i % 10 + j % 10 >= 10) return -1;
        res += (i + j) % 10 * TEN(d);
      } else {
        res += (i + j) % 10 * TEN(d);
      }
      i /= 10, j /= 10;
    }
    return res;
  };

  vector<long long> ans(TEN(k));
  auto dfs = [&](auto rc, int depth, int s) -> void {
    // cerr<<depth<<" "<<s<<endl;
    if (s == -1) return;
    if (depth == m) {
      ans[s]++;
      return;
    }
    for (int i = 0; i < n; i++) rc(rc, depth + 1, sm(s, a[i]));
  };
  dfs(dfs, 0, 0);

  for (int i = 0; i < TEN(k); i++) cout << ans[i] << "\n";
}
0