QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740061 | #9727. Barkley III | lonelywolf | Compile Error | / | / | C++23 | 3.4kb | 2024-11-13 00:46:06 | 2024-11-13 00:46:07 |
Judging History
你现在查看的是最新测评结果
- [2025-01-13 03:55:43]
- hack成功,自动添加数据
- (/hack/1447)
- [2024-11-13 00:46:07]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-11-13 00:46:06]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
struct Tag {
ull val = -1;
void apply(const Tag &t) {
val &= t.val;
}
};
struct Info {
ull val = -1, flg1 = -1, flg2 = 0;
int len = 1;
void apply(const Tag &t) {
val &= t.val;
if (len == 1) {
flg1 = val;
flg2 = ~val;
} else {
flg1 &= t.val;
flg2 &= t.val;
}
}
};
Info operator+(const Info &a, const Info &b) {
return {a.val & b.val, a.flg1 & b.flg1, (a.flg1 & b.flg2) | (b.flg1 & a.flg2), a.len + b.len};
}
const int N = 1000001;
Info info[N << 2];
Tag tag[N << 2];
int n;
void pull(int p) {
info[p] = info[p << 1] + info[p << 1 | 1];
}
void apply(int p, const Tag &v) {
info[p].apply(v);
tag[p].apply(v);
}
void push(int p) {
::apply(2 * p, tag[p]);
::apply(2 * p + 1, tag[p]);
tag[p] = Tag();
}
void modify(int p, int l, int r, int x, const Info &v) {
if (l == r) {
info[p] = v;
return;
}
int m = (l + r) / 2;
push(p);
if (x <= m) {
modify(2 * p, l, m, x, v);
} else {
modify(2 * p + 1, m + 1, r, x, v);
}
pull(p);
}
void modify(int p, const Info &v) {
modify(1, 1, n, p, v);
}
Info rangeQuery(int p, int l, int r, int x, int y) {
if (l > y || r < x) {
return Info();
}
if (l >= x && r <= y) {
return info[p];
}
int m = (l + r) / 2;
push(p);
return rangeQuery(2 * p, l, m, x, y) + rangeQuery(2 * p + 1, m + 1, r, x, y);
}
Info rangeQuery(int l, int r) {
return rangeQuery(1, 1, n, l, r);
}
void rangeApply(int p, int l, int r, int x, int y, const Tag &v) {
if (l > y || r < x) {
return;
}
if (l >= x && r <= y) {
apply(p, v);
return;
}
int m = (l + r) / 2;
push(p);
rangeApply(2 * p, l, m, x, y, v);
rangeApply(2 * p + 1, m + 1, r, x, y, v);
pull(p);
}
void rangeApply(int l, int r, const Tag &v) {
return rangeApply(1, 1, n, l, r, v);
}
template<class F>
int findFirst(int p, int l, int r, int x, int y, const F &pred) {
if (l > y || r < x || !pred(info[p])) {
return -1;
}
if (l == r) {
return l;
}
int m = (l + r) / 2;
push(p);
int res = findFirst(2 * p, l, m, x, y, pred);
if (res == -1) {
res = findFirst(2 * p + 1, m + 1, r, x, y, pred);
}
return res;
}
template<class F>
int findFirst(int l, int r, const F &pred) {
return findFirst(1, 1, n, l, r, pred);
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int q;
cin >> n >> q;
for (int i = 1; i <= n; i++) {
ull x;
cin >> x;
modify(i, {x, x, ~x, 1});
}
while (q--) {
int o;
cin >> o;
if (o == 1) {
int l, r;
ull x;
cin >> l >> r >> x;
rangeApply(l, r, {x});
} else if (o == 2) {
int p;
ull x;
cin >> p >> x;
modify(p, {x, x, ~x, 1});
} else {
int l, r;
cin >> l >> r;
auto [v, a, b, _] = rangeQuery(l, r);
if (b == 0) {
cout << v << "\n";
continue;
}
int k = __lg(b);
int pos = findFirst(l, r, [&](Info p) {
return !(p.val >> k & 1);
});
Info ans;
if (pos != l) {
ans = ans + rangeQuery(l, pos - 1);
}
if (pos != r) {
ans = ans + rangeQuery(pos + 1, r);
}
cout << ans.val << "\n";
}
}
return 0;
}
Details
answer.code:169:1: fatal error: error writing to /tmp/ccAzAg5z.s: File too large 169 | } | ^ compilation terminated.