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 "horses.h"
using namespace std;
#define M 500005
int n, x[M], y[M];
long long tmp, mod = 1e9 + 7;
struct segment{
int ans, mul;
double a = 0, m = 0;
} s[4 * M];
void update(int node, int l, int r, int idx, int valx, int valy){
if (idx < l || r < idx) return;
if (l == r){
if (valx) x[l] = valx;
if (valy) y[l] = valy;
tmp = (1ll * x[l] * y[l]) % mod;
s[node].ans = int(tmp);
s[node].mul = x[l];
s[node].m = log10(x[l]);
s[node].a = log10(1ll * x[l] * y[l]);
return;
}
int mid = (l + r)/2;
update(node * 2, l, mid, idx, valx, valy);
update(node * 2 + 1, mid + 1, r, idx, valx, valy);
s[node].m = s[node * 2].m + s[node * 2 + 1].m;
tmp = (1ll * s[node * 2].mul * s[node * 2 + 1].mul) % mod;
s[node].mul = int(tmp);
if (s[node * 2].a > s[node * 2 + 1].a + s[node * 2].m){
s[node].ans = s[node * 2].ans;
s[node].a = s[node * 2].a;
}
else{
tmp = (1ll * s[node * 2 + 1].ans * s[node * 2].mul ) % mod;
s[node].ans = int(tmp);
s[node].a = s[node * 2 + 1].a + s[node * 2].m;
}
}
int init(int N, int X[], int Y[]) {
n = N;
for (int i = 0;i < n;i++)
update(1, 0, n - 1, i, X[i], Y[i]);
return s[1].ans;
}
int updateX(int pos, int val) {
update(1, 0, n - 1, pos, val, 0);
return s[1].ans;
}
int updateY(int pos, int val) {
update(1, 0, n - 1, pos, 0, val);
return s[1].ans;
}
# | 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... |