rt,报错信息:Nothing is compiled: OUTPUT exceeds.
code :
#include <bits/stdc++.h>
#define ll long long
#define db double
#define vec vector
#define pll pair<ll, ll>
#define mkp make_pair
#define endl "\n"
using namespace std;
const ll mod = 998244353;
// namespace fastio {
// char buf[1 << 21], *p1 = buf, *p2 = buf;
// const ll getc() {
// return p1 == p2 && ( p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1 ++;
// }
// const ll read() {
// ll x = 0, f = 1;
// char ch = getc();
// while (ch < '0' || ch > '9') {
// if (ch == '-') f = -1; ch = getc();
// }
// while (ch >= '0' && ch <= '9') {
// x = (x << 1) + (x << 3) + (ch ^ 48), ch = getc();
// }
// return x * f;
// }
// const void write(ll x) {
// if (x < 0) {
// putchar('-'), x = -x;
// }
// ll sta[35], top = 0;
// do {
// sta[top++] = x % 10, x /= 10;
// } while (x);
// while (top) putchar(sta[--top] + 48);
// }
// }
// #define rd fastio::read
// #define wt fastio::write
// #define gc fastio::getc
#define ls (u << 1)
#define rs (u << 1 | 1)
ll n, m, q, a[200005], b[200005]; string s;
ll opt, l, r, ans = 0;
struct segment {
ll l = 1e18, r = -1e18, mxa = -1e18, mnb = -1e18, ml = -1e18, mr = -1e18, ans = -1e18;
friend segment operator + (segment a, segment b) {
segment c; c.l = min(a.l, b.l), c.r = max(a.r, b.r);
c.mxa = max(a.mxa, b.mxa), c.mnb = min(a.mnb, b.mnb);
c.ml = max(b.mxa - a.mnb, max(a.ml, b.ml)), c.mr = max(a.mxa - b.mnb, max(a.mr, b.mr));
c.ans = max(a.mr + b.mxa, max(a.mxa + b.ml, max(a.ans, b.ans)));
return c;
}
} w[800005] ;
void pushup(ll u) {
w[u] = w[ls] + w[rs];
return ;
}
void build(ll u, ll l, ll r) {
w[u].l = l, w[u].r = r;
if (l == r) {
w[u].mxa = a[l], w[u].mnb = b[l];
// w[u].ml = w[u].mr = w[u].ans = -1e18;
// cout << u << " " << w[u].l << " " << w[u].r << " " << w[u].mxa << " " << w[u].mnb << " " << w[u].ml << " " << w[u].mr << " " << w[u].ans << endl;
return ;
}
ll md = l + ((r - l) >> 1);
build(ls, l, md), build(rs, md + 1, r);
pushup(u);
// cout << u << " " << w[u].l << " " << w[u].r << " " << w[u].mxa << " " << w[u].mnb << " " << w[u].ml << " " << w[u].mr << " " << w[u].ans << endl;
}
void modifya(ll u, ll pos, ll x) {
if (w[u].l == w[u].r && w[u].l == pos) {
w[u].mxa = x; return ;
}
ll md = w[u].l + ((w[u].r - w[u].l) >> 1);
if (pos <= md) modifya(u << 1, pos, x);
else modifya(u << 1 | 1, pos, x);
pushup(u);
}
void modifyb(ll u, ll pos, ll x) {
if (w[u].l == w[u].r && w[u].l == pos) {
w[u].mnb = x; return ;
}
ll md = w[u].l + ((w[u].r - w[u].l) >> 1);
if (pos <= md) modifyb(u << 1, pos, x);
else modifyb(u << 1 | 1, pos, x);
pushup(u);
}
segment query(ll u, ll l, ll r) {
if (l <= w[u].l && w[u].r <= r) {
return w[u];
}
ll md = w[u].l + ((w[u].r - w[u].l) >> 1); segment res, lt, rt;
if (l <= md) {
lt = query(ls, l, r);
}
if (r > md) {
rt = query(rs, l, r);
}
// cout << w[u].l << " " << w[u].r << " " << res.ans << endl;
res = lt + rt;
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
ll i, x, y;
cin >> n >> m;
for (i = 1; i <= n; i++) cin >> a[i];
for (i = 1; i <= n; i++) cin >> b[i];
build(1, 1, n);
while (m--) {
cin >> opt >> x >> y;
if (opt == 1) {
modifya(1, x, y);
} else if (opt == 2) {
modifyb(1, x, y);
} else {
cout << (query(1, x, y)).ans << endl;
}
}
return 0;
}
有无人帮忙看眼 qwq