Submission #69832

#TimeUsernameProblemLanguageResultExecution timeMemory
69832VahanHorses (IOI15_horses)C++17
17 / 100
377 ms54756 KiB
#include "horses.h" #include<cmath> #include<iostream> using namespace std; pair<double,long long> t[3000000]; double lp[600000]; long long p[600000],n,x[600000],y[600000]; long long mod=1000000007; void build(int l,int r,int v) { if(l==r) { t[v].first=lp[l]; t[v].second=p[l]; return; } int mid=(l+r)/2; build(l,mid,2*v); build(mid+1,r,2*v+1); t[v]=max(t[2*v],t[2*v+1]); } void update(int L,int R,int l,int r,int v,int e,double f) { if(l>r) return; if(l==L && r==R) { t[v].first+=f; t[v].second*=e; t[v].second%=mod; return; } int mid=(L+R)/2; update(L,mid,l,min(mid,r),2*v,e,f); update(mid+1,R,max(l,mid+1),r,2*v+1,e,f); t[v]=max(t[2*v],t[2*v+1]); } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<n;i++) { x[i]=X[i]; y[i]=Y[i]; } for(int i=0;i<N;i++) { p[i]=X[i]; lp[i]+=log(X[i]); if(i>0) { p[i]=(p[i]*p[i-1])%mod; lp[i]+=lp[i-1]; } } for(int i=0;i<N;i++) { p[i]=(p[i]*Y[i])%mod; lp[i]+=log(Y[i]); } build(0,n-1,1); return t[1].second; } long long binpow(long long a,long long b) { if(b==0) return 1; if(b%2==0) { long long arm=binpow(a,b/2); return (arm*arm)%mod; } return (a*binpow(a,b-1))%mod; } int updateX(int pos, int val) { int e=(binpow(x[pos],mod-2)*val)%mod; double f=log(val)-log(x[pos]); x[pos]=val; update(0,n-1,pos,n-1,1,e,f); return t[1].second; } int updateY(int pos, int val) { int e=(binpow(y[pos],mod-2)*val)%mod; double f=log(val)-log(y[pos]); y[pos]=val; update(0,n-1,pos,pos,1,e,f); return t[1].second; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:60:14: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     build(0,n-1,1);
             ~^~
horses.cpp:61:14: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return t[1].second;
         ~~~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:75:37: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     int e=(binpow(x[pos],mod-2)*val)%mod;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:78:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     update(0,n-1,pos,n-1,1,e,f);
              ~^~
horses.cpp:78:23: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     update(0,n-1,pos,n-1,1,e,f);
                      ~^~
horses.cpp:79:14: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return t[1].second;
         ~~~~~^~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:83:37: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     int e=(binpow(y[pos],mod-2)*val)%mod;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:86:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     update(0,n-1,pos,pos,1,e,f);
              ~^~
horses.cpp:87:14: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return t[1].second;
         ~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...