求助大佬, 为什么全RE了, 在本地跑没问题呀
查看原帖
求助大佬, 为什么全RE了, 在本地跑没问题呀
440870
油炸皮卡丘0vo楼主2022/3/4 16:42

如题, 全RE了, 不知道哪出错了qwq

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 1e5 + 5;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;

int n, q, a[N];
int block;
struct Query {
    int op, l, r, x, id;
    bool operator < (const Query &o) const {
        return l / block == o.l / block ? r < o.r : l / block < o.l < block;
    }
} Q[N];
bitset< N > d1, d2;
int cnt[N], ans[N], res;
void add(int x) {
    if (++ cnt[a[x]] == 1) {
        d1[a[x]] = d2[100000 - a[x]] = true;
    }
}
void del(int x) {
    if (-- cnt[a[x]] == 0) {
        d1[a[x]] = d2[100000 - a[x]] = false;
    }
}
void solve() {
    cin >> n >> q;
    block = sqrt(n);
    for (int i = 1; i <= n; ++ i) {
        cin >> a[i];
    }
    for (int i = 1; i <= q; ++ i) {
        auto &[op, l, r, x, id] = Q[i];
        cin >> op >> l >> r >> x;
        id = i;
    }
    // a - b = x, a = b + x;
    sort(Q + 1, Q + q + 1);
    int L = 1, R = 0;
    for (int i = 1; i <= q; ++ i) {
        auto &[op, l, r, x, id] = Q[i];
        while (L > l) add(-- L);
        while (R < r) add(++ R);
        while (L < l) del(L ++ );
        while (R > r) del(R -- );
        if (op == 1) {
            ans[id] = (d1 & (d1 << x)).any();
        } else if (op == 2) {
            ans[id] = (d1 & (d2 >> (100000 - x))).any();
        } else {
            for (int j = 1; j * j <= x; ++ j) {
                if (!(x % j) && d1[x] && d1[x / j]) {
                    ans[id] = 1; break;
                }
            }
        }
    }
    for (int i = 1; i <= q; ++ i) {
        cout << (ans[i] ? "hana" : "bi") << '\n';
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int test = 1;
    //cin >> test;
    while (test -- ) solve();
    return 0;
}
2022/3/4 16:42
加载中...