QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#153539#2587. 荣誉称号eikkiCompile Error//C++202.3kb2023-08-30 10:38:382023-08-30 10:38:38

Judging History

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

  • [2023-08-30 10:38:38]
  • 评测
  • [2023-08-30 10:38:38]
  • 提交

answer

#include <iostream>
#include <vector>
#include <climits>
typedef long long ll;

int a[10000001], b[10000001];
ll c[(1 << 12) + 5][205];
bool mem[(1 << 12) + 5][205];
ll cache[(1 << 12) + 5][205];
bool mem2[(1 << 12) + 5][205];
ll cache2[(1 << 12) + 5][205];

unsigned int SA, SB, SC; ll p, A, B, n, k, m;

unsigned int rng61(){
    SA ^= SA << 16;
    SA ^= SA >> 5;
    SA ^= SA << 1;
    unsigned int t = SA;
    SA = SB;
    SB = SC;
    SC ^= t ^ SA;
    return SC;
}

void gen(){
    std::cin >> n >> k >> m >> p >> SA >> SB >> SC >> A >> B;
    for(int i = 1; i <= p; i++) std::cin >> a[i] >> b[i];
    for(int i = p + 1; i <= n; i++) {
        a[i] = rng61() % A + 1;
        b[i] = rng61() % B + 1;
    }
}

ll cost(int i, int q) {
    if (mem2[i][q]) return cache2[i][q];
    ll sum = 0;
    for (int e = 0; e < m; e++) {
        sum += ((q - e + m) % m) * c[i][e];
    }
    mem2[i][q] = true;
    return cache2[i][q] = sum;
}

ll dp(int node, int sum) {
    if (mem[node][sum]) return cache[node][sum];
    if (node < (1 << k)) {
        ll best = LLONG_MAX/32;
        for (int i = 0; i < m; i++) {
            int new_sum = (sum - i + m) % m;
            best = std::min(best, cost(node, i) + dp(2*node, new_sum) + dp(2*node+1, new_sum));
        }
        mem[node][sum] = true;
        return cache[node][sum] = best;
    }
    mem[node][sum] = true;
    return cache[node][sum] = cost(node, sum);
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int T;
    std::cin >> T;
    while (T--) {
        std::memset(a, 0, sizeof a);
        std::memset(b, 0, sizeof b);
        for (int j = 0; j < (1 << 12) + 5; j++) {
            for (int k1 = 0; k1 < 205; k1++) {
                c[j][k1] = 0;
                mem[j][k1] = false;
                cache[j][k1] = 0;
                mem2[j][k1] = false;
                cache2[j][k1] = 0;
            }
        }
        gen();
        for(int i = 1; i <= p; i++) {
            int j = i;
            while (j >= (1 << k + 1)) j >>= k + 1;
            c[j][a[i] % m] += b[i];
        }
        for(int i = p + 1; i <= n; i++){
            int j = i;
            while (j > (1 << k + 1)) j >>= k + 1;
            c[j][a[i] % m] += b[i];
        }
        std::cout << dp(1, 0) << std::endl;
    }
}

Details

answer.code: In function ‘int main()’:
answer.code:66:14: error: ‘memset’ is not a member of ‘std’; did you mean ‘wmemset’?
   66 |         std::memset(a, 0, sizeof a);
      |              ^~~~~~
      |              wmemset
answer.code:67:14: error: ‘memset’ is not a member of ‘std’; did you mean ‘wmemset’?
   67 |         std::memset(b, 0, sizeof b);
      |              ^~~~~~
      |              wmemset