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;
#define F first
#define S second
const ll mod=1e9+7;
ll n;
ll a[500001], b[500001];
pair<pair<ll, ll>, pair<ll, ll>> st[1000001];
void f(ll xf){
if(st[xf*2+1].S.F==1){
st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {1, st[xf*2+1].S.S}};
}
else{
if(st[xf*2].F.S<st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S){
st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {(st[xf*2].S.F||(st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S*st[xf*2].F.F)>=1000000000), st[xf*2+1].S.S}};
}
else{
st[xf]=st[xf*2];
st[xf].S.S*=st[xf*2+1].S.S*st[xf*2+1].F.F;
}
}
return ;
}
void update(ll xf){
xf/=2;
while(xf>0){
f(xf);
xf/=2;
}
return ;
}
int init(int N, int X[], int Y[]) {
n=N;
for(int i=0; i<N; i++){
a[i]=X[i];
b[i]=Y[i];
}
for(int i=0; i<n; i++){
st[i+n]={{a[i], b[i]}, {(a[i]*b[i]>=1000000000), 1}};
}
for(int i=n-1; i>0; i--){
f(i);
}
return (st[1].F.F*st[1].F.S)%mod;
}
int updateX(int pos, int val) {
a[pos]=val;
st[pos+n]={{a[pos], b[pos]}, {(a[pos]*b[pos]>=1000000000), 1}};
update(pos+n);
return (st[1].F.F*st[1].F.S)%mod;
}
int updateY(int pos, int val) {
b[pos]=val;
st[pos+n]={{a[pos], b[pos]}, {(a[pos]*b[pos]>=1000000000), 1}};
update(pos+n);
return (st[1].F.F*st[1].F.S)%mod;
}
Compilation message (stderr)
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:43:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
43 | for(int i=n-1; i>0; i--){
| ~^~
horses.cpp:46:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
46 | return (st[1].F.F*st[1].F.S)%mod;
| ~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:53:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
53 | return (st[1].F.F*st[1].F.S)%mod;
| ~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:60:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
60 | return (st[1].F.F*st[1].F.S)%mod;
| ~~~~~~~~~~~~~~~~~~~~~^~~~
# | 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... |