# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056208 | Muhammad_Aneeq | Horses (IOI15_horses) | C++17 | 238 ms | 72376 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 <cmath>
#include <vector>
using namespace std;
int const MAXN=5e5+10,mod=1e9+7;
vector<int>x,y;
struct node
{
long long val,maxval;
long double cnt,maxcnt;
};
node seg[4*MAXN]={};
void update(int i,int r,int st,int en)
{
if (st==en)
{
seg[i].val=seg[i].maxval=x[r];
seg[i].maxval*=y[r];
seg[i].maxval%=mod;
seg[i].cnt=log2(x[r]);
seg[i].maxcnt=seg[i].cnt+log2(y[r]);
return ;
}
int mid=(st+en)/2;
if (r<=mid)
update(i*2,r,st,mid);
else
update(i*2+1,r,mid+1,en);
int lc=i*2,rc=i*2+1;
seg[i].val=(seg[lc].val*seg[rc].val)%mod;
seg[i].cnt=seg[lc].cnt+seg[rc].cnt;
if (seg[lc].maxcnt<seg[lc].cnt+seg[rc].maxcnt)
{
seg[i].maxcnt=seg[lc].cnt+seg[rc].maxcnt;
seg[i].maxval=(seg[lc].val*seg[rc].maxval)%mod;
}
else
{
seg[i].maxcnt=seg[lc].maxcnt;
seg[i].maxval=seg[lc].maxval;
}
}
int init(int N, int X[], int Y[])
{
for (int i=0;i<N;i++)
{
x.push_back(X[i]);
y.push_back(Y[i]);
}
for (int i=0;i<N;i++)
update(1,i,0,N-1);
return seg[1].maxval;
}
int updateX(int pos, int val)
{
x[pos]=val;
update(1,pos,0,x.size()-1);
return seg[1].maxval;
}
int updateY(int pos, int val)
{
y[pos]=val;
update(1,pos,0,x.size()-1);
return seg[1].maxval;
}
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... |