QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153529#2587. 荣誉称号eikkiCompile Error//C++202.4kb2023-08-30 10:12:272023-08-30 10:12:27

Judging History

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

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

answer

#include <iostream>
#include <vector>
#include <climits>

long long c[(1 << 12) + 5][205];
bool mem[(1 << 12) + 5][205];
long long cache[(1 << 12) + 5][205];
bool mem2[(1 << 12) + 5][205];
long long cache2[(1 << 12) + 5][205];

unsigned int SA, SB, SC; long long 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++) {
        int ai, bi;
        std::cin >> ai >> bi;
        int j = i;
        while (j >= (1 << k + 1)) j >>= k + 1;
        c[j][ai % m] += bi;
    }
    for(int i = p + 1; i <= n; i++){
        int j = i;
        while (j > (1 << k + 1)) j >>= k + 1;
        int ai = rng61() % A + 1;
        int bi = rng61() % B + 1;
        c[j][ai % m] += bi;
    }
}

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

long long dp(int node, int sum) {
    if (mem[node][sum]) return cache[node][sum];
    if (node < (1 << k)) {
        long long 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--) {
        memset(c, 0, sizeof c);
        memset(mem, 0, sizeof mem);
        memset(cache, 0, sizeof cache);
        memset(mem2, 0, sizeof mem2);
        memset(cache2, 0, sizeof cache2);
        // 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();
        std::cout << dp(1, 0) << std::endl;
    }
}

详细

answer.code: In function ‘int main()’:
answer.code:73:9: error: ‘memset’ was not declared in this scope
   73 |         memset(c, 0, sizeof c);
      |         ^~~~~~
answer.code:4:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    3 | #include <climits>
  +++ |+#include <cstring>
    4 |