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>
#define fi first
#define se second
#define lo long long
#define inf 1000000009
#define md 1000000007
#define li 500005
#define mp make_pair
#define pb push_back
#define mid (start+end)/2
using namespace std;
int n,A1[li],B1[li],A[li],B[li];
double tree[li*4],lazy[li*4];
int pw(int a,int b){
if(b==0) return 1;
if(b==1) return a;
int t=pw(a,b/2);
t=t*t;
if(b%2==1) t=t*a;
return t;
}
void build(int node,int start,int end){
if(start==end){
tree[node]=A[start]*B[start];
return ;
}
build(node*2,start,mid);build(node*2+1,mid+1,end);
tree[node]=max(tree[node*2],tree[node*2+1]);
}
void push(int node,int start,int end){
if(lazy[node]==0) return ;
tree[node]*=pw(lazy[node],end-start+1);
if(start!=end){
if(lazy[node*2]==0) lazy[node*2]=lazy[node];
else lazy[node*2]*=lazy[node];
if(lazy[node*2+1]==0) lazy[node*2+1]=lazy[node];
else lazy[node*2+1]*=lazy[node];
}
lazy[node]=0;
}
double query(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l) return -inf;
push(node,start,end);
if(start>=l && end<=r) return tree[node];
double q1=query(node*2,start,mid,l,r);
double q2=query(node*2+1,mid+1,end,l,r);
return max(q1,q2);
}
int init(int N,int X[],int Y[]){
n=N;
for(int i=0;i<n;i++) A[i+1]=X[i];
for(int i=0;i<n;i++) B[i+1]=Y[i];
for(int i=1;i<=n;i++){
A[i]*=(i!=1?A[i-1]:1);
}
build(1,1,n);
int bas=(int)query(1,1,n,1,n);
return bas;
}
void update(int node,int start,int end,int l,int r,double val){
push(node,start,end);
if(start>end || start>r || end<l) return ;
if(start>=l && end<=r){
if(lazy[node]==0) lazy[node]=val;
else lazy[node]*=val;
push(node,start,end);
return ;
}
update(node*2,start,mid,l,r,val);update(node*2+1,mid+1,end,l,r,val);
tree[node]=max(tree[node*2],tree[node*2+1]);
}
int updateX(int pos,int val){
//A[pos+1]=val;
pos++;
double ggwp=val,htht=A[pos];
update(1,1,n,pos,n,ggwp/htht);
int bas=(int)query(1,1,n,1,n);
return bas;
}
int updateY(int pos,int val){
pos++;
double ggwp=val,htht=B[pos];
update(1,1,n,pos,pos,ggwp/htht);
int bas=(int)query(1,1,n,1,n);
return bas;
}
//~ int main(){
//~ scanf("%d",&n);
//~ for(int i=0;i<n;i++) scanf("%d",&A1[i]);
//~ for(int i=0;i<n;i++) scanf("%d",&B1[i]);
//~ int ty=init(n,A1,B1);
//~ ty=updateY(1,2);
//~ printf("%d\n",ty);
//~ return 0;
//}
Compilation message (stderr)
horses.cpp: In function 'void push(int, int, int)':
horses.cpp:33:26: warning: conversion to 'int' from 'double' may alter its value [-Wfloat-conversion]
tree[node]*=pw(lazy[node],end-start+1);
~~~~~~~~~^
# | 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... |