Hack
查看原帖
Hack
746760
User_Unauthorized楼主2024/1/2 14:47

虽然 RMJ 不能添加 Hack 数据,但还是发出来以防止误导后人。

现在本题题解区的第一篇题解,即 @Nagisa_Tomoya 的题解。在正确性上存在严重问题。

首先,下面的数据生成器可以使得其正确率为 (BN)Q\left(\dfrac{B}{N}\right)^Q,其中 BB 为其题解中的随机次数。其次,其通过随机下标验证的部分由于测试数据中无解的数据较多导致其“剪枝”效果良好,所以没有导致超时。但是通过构造数据可以使其进行 O(qB)\mathcal{O}(qB) 次左右查询,本机大约需要 1010 秒才能跑完。

#include "testlib.h"
#include <bits/stdc++.h>

constexpr int MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    registerGen(argc, argv, 1);

    int const N = opt<int>("N", 2e5), Q = opt<int>("Q", 2e5);

    std::vector<int> d(N);

    int const base = rnd.next(200, MOD - 1);

    std::fill(d.begin(), d.end(), base);

    d.front() = rnd.next(MOD);

    int const pos = rnd.next(1, N - 3);

    d[pos] -= 1;
    d[pos + 1] += 2;
    d[pos + 2] -= 1;

    for (int i = 1; i < N; ++i)
        d[i] = (d[i] + d[i - 1]) % MOD;

    std::cout << N << " " << Q << "\n";

    for (int i = 0; i < N; ++i)
        std::cout << d[i] << " ";

    std::cout << "\n";

    for (int i = 0; i < Q; ++i) {
        int const l = rnd.wnext(1, pos, -10), r = rnd.wnext(pos + 1, N, 10);

        std::cout << l << " " << r << " " << base << "\n";
    }

    std::cout << std::flush;

    return 0;
}
2024/1/2 14:47
加载中...