QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#447027#8527. Power Divisionsucup-team3215Compile Error//C++202.7kb2024-06-17 20:27:122024-06-17 20:27:12

Judging History

你现在查看的是最新测评结果

  • [2024-06-17 20:27:12]
  • 评测
  • [2024-06-17 20:27:12]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 3e5 + 1, exps[]{37, 11, 9, 8, 7, 5};
using E = array<uint64_t, size(exps)>;
constexpr uint64_t mod = -49ull / 2;

template <typename V>
struct umap {
  vector<uint64_t> keys;
  vector<V> vals;
  vector<uint32_t> nx;
  vector<uint32_t> head;
  int cap{};

  int geti(uint64_t k) {
    reserve();
    for (int i = head[k & cap]; ~i; i = nx[i]) if (keys[i] == k) return i;
    nx.push_back(head[k & cap]);
    head[k & cap] = keys.size();
    keys.push_back(k);
    vals.push_back({});
    return vals.size() - 1;
  }

  void reserve() {
    if (keys.size() * 2 < cap) return;
    cap = max(cap * 2 + 1, 6);
    head.assign(cap + 1, -1);
    nx.clear();
    for (int i = 0; i < keys.size(); ++i) {
      nx.push_back(head[keys[i] & cap]);
      head[keys[i] & cap] = i;
    }
  }
};

template <int i>
struct um: conditional_t<i == size(exps), vector<int>, umap<um<i + 1>>> { };

um<0> m;

vector<int> ls[N];

template <int i = 0>
auto& mget(const E& e, auto& m) {
  if constexpr (i == size(exps)) return m;
  else return mget<i + 1>(e, m[e[i]]);
}

template <int i = 0>
void walk(const E& e, auto& m, uint64_t k, uint64_t pr, auto f) {
  if constexpr (i == size(exps)) f(m, k, pr);
  else {
    uint64_t step = pr;
    while (step % exps[i] != 1) step += pr;
    while (k % exps[i]) k += pr;
    pr *= exps[i];
    if (m.size() != 1)
    for (int j = 0; j < exps[i]; ++j) {
      auto it = m.find((e[i] + (1ull << exps[i]) - 1 - (1ull << j)) % ((1ull << exps[i]) - 1));
      if (it != m.end()) walk<i + 1>(e, it->second, k, pr, f);
      k = (k + step) % pr;
    }
    else if (auto& [ke, v] = *m.begin(); 1)
    for (int j = 0; j < exps[i]; ++j) {
      if ((e[i] + (1ull << exps[i]) - 1 - (1ull << j)) % ((1ull << exps[i]) - 1) == ke) walk<i + 1>(e, v, k, pr, f);
      k = (k + step) % pr;
    }
  }
}

int dp[N];

uint64_t pw[(int)1.1e6];
uint64_t pss[N];

int main() {
  cin.tie(0)->sync_with_stdio(0);
  pw[0] = 1;
  for (uint64_t i = 1, p = 2; i < size(pw); ++i) pw[i] = p, p = (p + p) % mod;
  int n; cin >> n;
  E ps{};
  uint64_t psm{};
  for (int i = 0; ; ++i) {
    mget(ps, m).push_back(i);
    walk(ps, m, 0, 1, [&](auto& v, auto k, auto p) { for (auto& j: v) if (pss[j] == (psm + mod - pw[k]) % mod) ls[i].push_back(j); });
    pss[i] = psm;
    if (i == n) break;
    int v; cin >> v;
    for (int j = 0; j < size(exps); ++j) ps[j] = (ps[j] + (1ull << v % exps[j])) % ((1ull << exps[j]) - 1);
    psm = (psm + pw[v]) % mod;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; ++i)
  for (auto j: ls[i]) dp[i] = (dp[i] + dp[j]) % ((int)1e9 + 7);
  cout << dp[n];
}

详细

answer.code: In instantiation of ‘auto& mget(const E&, auto:54&) [with int i = 0; auto:54 = um<0>; E = std::array<long unsigned int, 6>]’:
answer.code:87:9:   required from here
answer.code:49:31: error: no match for ‘operator[]’ (operand types are ‘um<0>’ and ‘const std::array<long unsigned int, 6>::value_type’ {aka ‘const long unsigned int’})
   49 |   else return mget<i + 1>(e, m[e[i]]);
      |                              ~^
answer.code: In instantiation of ‘void walk(const E&, auto:55&, uint64_t, uint64_t, auto:56) [with int i = 0; auto:55 = um<0>; auto:56 = main()::<lambda(auto:57&, auto:58, auto:59)>; E = std::array<long unsigned int, 6>; uint64_t = long unsigned int]’:
answer.code:88:9:   required from here
answer.code:60:11: error: ‘struct um<0>’ has no member named ‘size’
   60 |     if (m.size() != 1)
      |         ~~^~~~
answer.code:62:19: error: ‘struct um<0>’ has no member named ‘find’
   62 |       auto it = m.find((e[i] + (1ull << exps[i]) - 1 - (1ull << j)) % ((1ull << exps[i]) - 1));
      |                 ~~^~~~
answer.code:63:19: error: ‘struct um<0>’ has no member named ‘end’
   63 |       if (it != m.end()) walk<i + 1>(e, it->second, k, pr, f);
      |                 ~~^~~
answer.code:66:33: error: ‘struct um<0>’ has no member named ‘begin’
   66 |     else if (auto& [ke, v] = *m.begin(); 1)
      |                               ~~^~~~~