This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define lso(x) x&(-x)
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
struct SegTree {
int n;
vi tr, lazy;
SegTree() {n = 0;}
void INTI(int N) {n = N; tr.assign(3*n,0); lazy.assign(3*n,0);}
int l(int i) {return i<<1;}
int r(int i) {return (i<<1)|1;}
ll combine(ll a, ll b) {return max(a, b);}
// void propagate_mult(int x, int L, int R) {
// if (lazy[x] == 0) return;
// if (R == L) {
// tr[x] /= oldmaxx[x];
// oldmaxx[x] = lazy[x];
// tr[x] *= lazy[x];
// return;
// }
// tr[x] /= oldmaxx[x];
// oldmaxx[x] = lazy[x];
// tr[x] *= lazy[x];
// lazy[l(x)] = lazy[r(x)] = lazy[x];
// lazy[x] = 0;
// }
void mult(int x, int L, int R, int i, ll ov, ll nv) {
if (i > R || i < L) return;
if (R == L) {
tr[x] /= ov;
tr[x] *= nv;
return;
}
int mid = (L + R) / 2;
mult(l(x), L, mid, i, ov, nv);
mult(r(x), mid + 1, R, i, ov, nv);
tr[x] = combine(tr[l(x)], tr[r(x)]);
}
void mult(int i, ll nv, ll ov) {
mult(1, 0, n - 1, i, nv, ov);
}
void assign(int x, int L, int R, int i, ll v) {
if (i < L ||i > R) return;
if (L == R) {
tr[x] = v;
return;
}
int mid = (L + R) / 2;
assign(l(x), L, mid, i, v);
assign(r(x), mid + 1, R, i, v);
tr[x] = combine(tr[l(x)], tr[r(x)]);
}
void assign(int i, ll v) {
assign(1, 0, n - 1, i, v);
}
ll query(int x, int L, int R, int i, int j) {
if (i > R || j < L) return 0;
if (L >= i && R <= j) return tr[x];
int mid = (L + R) / 2;
return combine(
query(l(x), L, mid, i, j),
query(r(x), mid + 1, R, i, j)
);
}
ll query(int i, int j) {
return query(1, 0, n - 1, i, j);
}
};
vi X, Y, T;
int N;
SegTree st;
int init(int a, int x[], int y[]) {
N = a;
X.resize(N); Y.resize(N); T.resize(N);
rep(i,0,N) X[i] = x[i];
rep(i,0,N) Y[i] = y[i];
rep(i,0,N) T[i] = X[i];
rep(i,1,N) T[i] = T[i] * T[i - 1];
st.INTI(N);
rep(i,0,N) st.assign(i, T[i] * Y[i]);
return st.query(0, N - 1) % 1000000009;
}
int updateX(int pos, int val) {
X[pos] = val;
rep(i,pos,N) {
if (i == 0) T[i] = X[i];
else T[i] = T[i - 1] * X[i];
}
rep(i,pos,N) st.assign(i, T[i] * Y[i]);
return st.query(0, N - 1) % 1000000009;
}
int updateY(int pos, int val) {
Y[pos] = val;
st.assign(pos, Y[pos]*T[pos]);
return st.query(0, N - 1) % 1000000009;
}
Compilation message (stderr)
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:105:29: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
105 | return st.query(0, N - 1) % 1000000009;
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:115:29: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
115 | return st.query(0, N - 1) % 1000000009;
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:121:29: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
121 | return st.query(0, N - 1) % 1000000009;
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |