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 <bits/stdc++.h>
#include "horses.h"
#define maxN 500005
#define mod 1000000007
using namespace std;
struct segment{
long long a,b;};
segment seg[4*maxN];
vector <int> x,y;
void build(int n,int l,int d){
if(l==d){
seg[n].a=x[l];
seg[n].b=x[l]*y[l]%mod;
}
else{
int m=(l+d)/2;
build(2*n,l,m);
build(2*n+1,m+1,d);
seg[n].a=(seg[2*n].a*seg[2*n+1].a)%mod;
seg[n].b=(max(seg[2*n].b,seg[2*n+1].b*seg[2*n].a))%mod;
}
}
void updatex(int n,int l,int d,int p,int v){
if(l==d){
x[l]=v;
seg[n].a=x[l];
seg[n].b=x[l]*y[l]%mod;
}
else{
int m=(l+d)/2;
if(p<=m) updatex(2*n,l,m,p,v);
else updatex(2*n+1,m+1,d,p,v);
seg[n].a=(seg[2*n].a*seg[2*n+1].a)%mod;
seg[n].b=(max(seg[2*n].b,seg[2*n+1].b*seg[2*n].a))%mod;
}
}
void updatey(int n,int l,int d,int p,int v){
if(l==d){
y[l]=v;
seg[n].a=x[l];
seg[n].b=x[l]*y[l]%mod;
}
else{
int m=(l+d)/2;
if(p<=m) updatey(2*n,l,m,p,v);
else updatey(2*n+1,m+1,d,p,v);
seg[n].a=(seg[2*n].a*seg[2*n+1].a)%mod;
seg[n].b=(max(seg[2*n].b,seg[2*n+1].b*seg[2*n].a))%mod;
}
}
int init(int n,int a[],int b[]){
int i;
for(i=0;i<n;i++){
x.push_back(a[i]);
y.push_back(b[i]);
}
build(1,0,n-1);
return seg[1].b;
}
int updateX(int pos,int val){
updatex(1,0,x.size()-1,pos,val);
return seg[1].b;
}
int updateY(int pos,int val){
updatey(1,0,y.size()-1,pos,val);
return seg[1].b;
}
Compilation message (stderr)
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:62:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return seg[1].b;
^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:65:31: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
updatex(1,0,x.size()-1,pos,val);
^
horses.cpp:66:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return seg[1].b;
^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:69:31: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
updatey(1,0,y.size()-1,pos,val);
^
horses.cpp:70:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return seg[1].b;
^
# | 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... |