# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88752 | David_M | Horses (IOI15_horses) | C++14 | 0 ms | 0 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;
struct ABC{int A, x, y; double X, Y, m;} a[2000010];
int n, u=1000000007;
void upd(int l, int r, int i, int k, int x, int y){
if(r<k || k<l) return;
if(l==k && l==r){
if(x) a[i].X=log10(x), a[i].x=x, a[i].m=a[i].X+a[i].Y;
if(y) a[i].Y=log10(y), a[i].y=y, a[i].m=a[i].X+a[i].Y;
a[i].A=a[i].x*a[i].y%u;
return;
}int L=i*2, R=i*2+1;
upd(l, (l+r)/2, L,k,x,y);
upd((l+r)/2+1,r,R,k,x,y);
a[i].X=a[L].X+a[R].X;
a[i].x=a[L].x*a[R].x%u;
if(a[L].m<a[R].m+a[L].X)
a[i].m=a[R].m+a[L].X,
a[i].A=a[R].A*a[L].x%u;
else
a[i].m=a[L].m,
a[i].A=a[L].A;
}
int init(int N,int X[],int Y[]){n=N; for(I=0;I<n;I++) upd(0,n-1,1,I,X[I],Y[I]); return a[1].A;}
int updateX(int pos,int val){upd(0,n-1,1,pos,val,0); return a[1].A;}
int updateY(int pos,int val){upd(0,n-1,1,pos,0,val); return a[1].A;}