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;
#define sz(v) ((int)(v).size())
typedef long long lint;
typedef pair<int,int> pii;
int Z=1e9+7;
int n;
int po(int p,int q)
{
if(q==0)return 1;
if(q==1)return p;
int o=po(p,q/2);
o=1ll*o*o%Z;
if(q%2)o=1ll*o*p%Z;
return o;
}
struct Tree{
long double l;
int v;
}seg[1<<20];
long double lazyL[1<<20];
int lazyV[1<<20];
int XX[500005],YY[500005];
void push(int num,int s,int e)
{
seg[num].l+=lazyL[num];
if(s!=e)
{
lazyL[2*num]+=lazyL[num];
lazyL[2*num+1]+=lazyL[num];
}
lazyL[num]=0;
seg[num].v=1ll*seg[num].v*lazyV[num]%Z;
if(s!=e)
{
lazyV[2*num]=1ll*lazyV[2*num]*lazyV[num]%Z;
lazyV[2*num+1]=1ll*lazyV[2*num+1]*lazyV[num]%Z;
}
lazyV[num]=1;
}
void update(int num,int s,int e,int l,int r,long double x,int z)
{
push(num,s,e);
if(s>r||l>e)return ;
if(l<=s&&e<=r)
{
seg[num].l+=x;
seg[num].v=1ll*seg[num].v*z%Z;
if(s!=e)
{
lazyL[num*2]+=x;
lazyL[num*2+1]+=x;
lazyV[num*2]=1ll*lazyV[num*2]*z%Z;
lazyV[num*2+1]=1ll*lazyV[num*2+1]*z%Z;
}
return ;
}
update(num*2,s,(s+e)/2,l,r,x,z);
update(num*2+1,(s+e)/2+1,e,l,r,x,z);
if(seg[num*2].l>seg[num*2+1].l)
{
seg[num].l=seg[num*2].l;
seg[num].v=seg[num*2].v;
}
else
{
seg[num].l=seg[num*2+1].l;
seg[num].v=seg[num*2+1].v;
}
}
int init(int N, int X[], int Y[]) {
n=N;
for(int i=1;i<min(4*n,(1<<20));i++)lazyV[i]=seg[i].v=1;
for(int i=0;i<n;i++)
{
long double x=log(X[i]);
long double y=log(Y[i]);
XX[i]=X[i];
YY[i]=Y[i];
update(1,0,n-1,i,n-1,x,X[i]);
update(1,0,n-1,i,i,y,Y[i]);
}
return seg[1].v;
}
int updateX(int pos, int val) {
long double x0=log(XX[pos]);
long double x1=log(val);
int mul=1ll*po(XX[pos],Z-2)*val%Z;
XX[pos]=val;
update(1,0,n-1,pos,n-1,x1-x0,mul);
return seg[1].v;
}
int updateY(int pos, int val) {
long double y0=log(YY[pos]);
long double y1=log(val);
int mul=1ll*po(YY[pos],Z-2)*val%Z;
YY[pos]=val;
update(1,0,n-1,pos,pos,y1-y0,mul);
return seg[1].v;
}
Compilation message (stderr)
horses.cpp: In function 'int po(int, int)':
horses.cpp:15:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
15 | o=1ll*o*o%Z;
| ~~~~~~~^~
horses.cpp:16:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
16 | if(q%2)o=1ll*o*p%Z;
| ~~~~~~~^~
horses.cpp: In function 'void push(int, int, int)':
horses.cpp:36:38: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
36 | seg[num].v=1ll*seg[num].v*lazyV[num]%Z;
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~
horses.cpp:39:43: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
39 | lazyV[2*num]=1ll*lazyV[2*num]*lazyV[num]%Z;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
horses.cpp:40:47: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
40 | lazyV[2*num+1]=1ll*lazyV[2*num+1]*lazyV[num]%Z;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
horses.cpp: In function 'void update(int, int, int, int, int, long double, int)':
horses.cpp:51:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
51 | seg[num].v=1ll*seg[num].v*z%Z;
| ~~~~~~~~~~~~~~~~^~
horses.cpp:56:35: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
56 | lazyV[num*2]=1ll*lazyV[num*2]*z%Z;
| ~~~~~~~~~~~~~~~~~~^~
horses.cpp:57:39: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
57 | lazyV[num*2+1]=1ll*lazyV[num*2+1]*z%Z;
| ~~~~~~~~~~~~~~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:93:33: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
93 | int mul=1ll*po(XX[pos],Z-2)*val%Z;
| ~~~~~~~~~~~~~~~~~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:102:33: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
102 | int mul=1ll*po(YY[pos],Z-2)*val%Z;
| ~~~~~~~~~~~~~~~~~~~~~~~^~
# | 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... |