#include "horses.h"
#include "bits/stdc++.h"
using namespace std;
const int N = 5e5 + 5;
const int md = (int) 1e9 + 7;
struct node {
long double mx = 0, lazy = 0;
};
int n;
int x[N], y[N];
node seg[N * 2];
int mul(int a, int b) {
return (int) ((long long) a * b % md);
}
void push(int nd, int l, int r) {
if (!seg[nd].lazy) return;
seg[nd].mx += seg[nd].lazy;
if (l != r) {
int mid = (l + r) >> 1;
int rs = nd + ((mid - l + 1) << 1);
seg[nd + 1].lazy += seg[nd].lazy;
seg[rs].lazy += seg[nd].lazy;
}
seg[nd].lazy = 0;
}
void upd(int nd, int l, int r, int s, int e, long double v) {
push(nd, l, r);
if (l >= s && r <= e) {
seg[nd].lazy = v;
push(nd, l, r);
cout << "L, R: " << l << ' ' << r << ' ' << seg[nd].mx << '\n';
return;
}
int mid = (l + r) >> 1;
int rs = nd + ((mid - l + 1) << 1);
if (mid >= e) {
upd(nd + 1, l, mid, s, e, v);
push(rs, mid + 1, r);
} else {
if (mid < s) {
upd(rs, mid + 1, r, s, e, v);
push(nd + 1, l, mid);
} else {
upd(nd + 1, l, mid, s, e, v);
upd(rs, mid + 1, r, s, e, v);
}
}
seg[nd].mx = max(seg[nd + 1].mx, seg[rs].mx);
}
int get(int nd, int l, int r) {
if (l == r) {
return l;
}
int mid = (l + r) >> 1;
int rs = nd + ((mid - l + 1) << 1);
push(nd + 1, l, mid);
push(rs, mid + 1, r);
if (seg[nd + 1].mx < seg[rs].mx) {
return get(rs, mid + 1, r);
} else {
return get(nd + 1, l, mid);
}
}
int calc(int index) {
int ret = 1;
for (int i = 0; i <= index; ++i) {
ret = mul(ret, x[i]);
}
return mul(ret, y[index]);
}
int init(int N_, int X[], int Y[]) {
n = N_;
for (int i = 0; i < n; ++i) {
x[i] = X[i]; y[i] = Y[i];
upd(0, 0, n - 1, i, i, log2(y[i]));
upd(0, 0, n - 1, i, n - 1, log2(x[i]));
}
return calc(get(0, 0, n - 1));
}
int updateX(int pos, int val) {
upd(0, 0, n - 1, pos, n - 1, -log2(x[pos]));
x[pos] = val;
upd(0, 0, n - 1, pos, n - 1, +log2(x[pos]));
return calc(get(0, 0, n - 1));
}
int updateY(int pos, int val) {
upd(0, 0, n - 1, pos, pos, -y[pos]);
y[pos] = val;
upd(0, 0, n - 1, pos, pos, +y[pos]);
return calc(get(0, 0, n - 1));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1517 ms |
73236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |