Sunny郭 @ 2023-10-04 15:05:40
#include <bits/stdc++.h>
using namespace std;
const int N = 39989, M = 1e9;
using T = long double;
const T eps = 1e-7;
int i, j, n, m, op, a, b, x, y, ls, rt, id;
struct func {
T k, b; int id;
func(T k=0, T b=-1e17, int id=0) : k(k), b(b), id(id){}
T operator () (int x) {return (T)(1.0 * k * x + b);}
};
struct yuki {
func tag[N + 7 << 1];
int L[N + 7 << 1], R[N + 7 << 1], tot;
func mv(func a, func b, int x) {return a(x) < b(x) ? b : a;}
func md(func a, func b, int x) {return a.id > b.id ? b : a;}
func mx(func a, func b, int x) {return a(x) == b(x) ? md(a, b, x) : mv(a, b, x);}
void ins(func f, int& p, int l, int r) {
if(!p) p = ++tot; int mid = l + r >> 1;
switch((f(l) <= tag[p](l)) + (f(r) <= tag[p](r))) {
case 0: tag[p] = f; break;
case 1: ins(f, L[p], l, mid), ins(f, R[p], mid + 1, r); break;
}
}
func query(int x, int p=rt, int l=1, int r=N) {
if(!p) return func(); int mid = l + r >> 1;
return mx(tag[p], x <= mid ? query(x, L[p], l, mid) : query(x, R[p], mid + 1, r), x);
}
void modify(int x, int y, func f, int& p=rt, int l=1, int r=N) {
if(!p) p = ++tot; int mid = l + r >> 1;
if(x <= l && r <= y) return ins(f, p, l, r);
if(x <= mid) modify(x, y, f, L[p], l, mid);
if(y > mid) modify(x, y, f, R[p], mid + 1, r);
}
} miku;
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n;
for(i=1; i<=n; i++) {
cin >> op;
if(op) {
cin >> a >> b >> x >> y;
a = (a + ls - 1) % N + 1;
b = (b + ls - 1) % N + 1;
x = (x + ls - 1) % M + 1;
y = (y + ls - 1) % M + 1;
func f; f.id = ++id;
if(x ^ a) {
f.k = (T)1.0 * (y - b) / (T)(x - a);
f.b = (T)(y - (T)f.k * x);
} else {
f.k = 0, f.b = max(y, b);
}
miku.modify(min(a, x), max(a, x), f);
} else {
cin >> x, x = (x + ls - 1) % N + 1;
cout << (ls = miku.query(x).id) << "\n";
}
}
return 0;
}
by UYHW @ 2023-10-04 15:09:21
我还想呢,这题怎么LCT()
by Argvchs @ 2023-10-04 15:10:35
LiChaoTree(
by Sunny郭 @ 2023-10-04 15:27:09
@Argvchs @UYHW 求调,hack全过了)正常的一个没过
by UYHW @ 2023-10-04 15:42:40
@Sunny郭 强制在线的模数错了
by Sunny郭 @ 2023-10-04 15:44:06
@UYHW orz,改错了
by Sunny郭 @ 2023-10-04 15:45:33
@UYHW 感谢