# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
393533 | bigg | Horses (IOI15_horses) | C++14 | 44 ms | 16900 KiB |
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 "horses.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5e5 + 10;
const ll MOD = 1e9 + 7;
ll prefx[MAXN], y[MAXN], x[MAXN];
int n;
ll exp(ll a, ll e){
if(e == 0) return 1;
if(e == 1) return a;
ll ans = exp(a, e/2)%MOD;
(ans*=ans)%=MOD;
if(e%2) (ans*=a)%=MOD;
return ans;
}
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];
prefx[i] = X[i];
if(i) (prefx[i]*=prefx[i-1])%=MOD;
}
ll ans = 0;
for(int i = max(0,n-31); i < n; i++){
ans = max(ans, (prefx[i]*y[i])%MOD);
}
return ans;
}
int updateX(int pos, int val) {
ll v = val;
if(n-pos > 32 ){
for(int i = n-31; i < n; i++ ){
(prefx[i] *= exp(x[pos], MOD - 2))%=MOD;
prefx[i] *= v;
prefx[i]%=MOD;
}
}else{
for(int i = pos; i < n; i++){
(prefx[i] *= exp(x[pos], MOD - 2))%=MOD;
prefx[i] *= v;
prefx[i]%=MOD;
}
}
ll ans = 0;
for(int i = max(0,n-31); i < n; i++){
ans = max(ans, (prefx[i]*y[i])%MOD);
}
x[pos] = val;
return ans;
}
int updateY(int pos, int val) {
y[pos] = val;
ll ans = 0;
for(int i = max(0,n-31); i < n; i++){
ans = max(ans, (prefx[i]*y[i])%MOD);
}
return ans;
}
Compilation message (stderr)
# | 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... |