Submission #71579

#TimeUsernameProblemLanguageResultExecution timeMemory
71579mr_bananaHorses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "horses.h" using namespace std; const int MN=5e5+100,mod=1e9+7; int n,x[MN],y[MN],seg[4*MN],mulx=1; set<int,greater<int> > more; int powm(int x1,int y1){ if(y1==0){ return 1; } int ans=powm(x1,y1/2); ans=(1ll*ans*ans)%mod; if(y1&1){ ans=(1ll*ans*x1)%mod; } return ans; } void build(int v=1,int s=0,int e=n){ if(e-s<2){ seg[v]=y[s]; return ; } int mid=(s+e)/2; build(2*v,s,mid); build(2*v+1,mid,e); seg[v]=max(seg[2*v],seg[2*v+1]); } void st(int p,int val,int v=1,int s=0,int e=n){ if(e-s<2){ seg[v]=val; return; } int mid=(s+e)/2; if(p<mid){ st(p,val,2*v,s,mid); } else{ st(p,val,2*v+1,mid,e); } seg[v]=max(seg[2*v],seg[2*v+1]); } int get(int l,int r,int v=1,int s=0,int e=n){ /*if(l<=s && e<=r){ return seg[v]; } if(l>=e || s>=r){ return 0; } int mid=(s+e)/2; return max(get(l,r,2*v,s,mid),get(l,r,2*v+1,mid,e));*/ int mx=0; for(int i=l;i<r;i++){ mx=max(mx,y[i]); } return mx; } int ans(){ /*long long mul=1,mulm=1,ym=0; for(int i:more){ int yi=get(i,n); if(mulm*yi>mul*ym){ ym=yi; mulm=mul; } mul=mul*x[i]; if(mul>mod){ break; } }*/ long long ans1=0,ym,=0,mul=mulx; for(int i=n-1;i>=0;i--){ ym=max(ym,y[i]); ans1=max(ans1,mul*ym); mul/=x[i]; } return ans1%mod;//(1ll*((mulx*powm(mulm,mod-2))%mod)*ym)%mod; } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<n;i++){ x[i]=X[i]; mulx=(1ll*mulx*x[i])%mod; y[i]=Y[i]; if(x[i]>1){ more.insert(i); } } more.insert(0); build(); return ans(); } int updateX(int pos, int val) { if(pos>0 && x[pos]>1 && val<2){ more.erase(pos); } if(pos>0 && x[pos]<2 && val>1){ more.insert(pos); } mulx=(1ll*mulx*powm(x[pos],mod-2))%mod; x[pos]=val; mulx=(1ll*mulx*x[pos])%mod; return ans(); } int updateY(int pos, int val) { y[pos]=val; st(pos,val); return ans(); }

Compilation message (stderr)

horses.cpp: In function 'int powm(int, int)':
horses.cpp:13:22: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     ans=(1ll*ans*ans)%mod;
         ~~~~~~~~~~~~~^~~~
horses.cpp:15:25: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         ans=(1ll*ans*x1)%mod;
             ~~~~~~~~~~~~^~~~
horses.cpp: In function 'int get(int, int, int, int, int)':
horses.cpp:43:27: warning: unused parameter 'v' [-Wunused-parameter]
 int get(int l,int r,int v=1,int s=0,int e=n){
                           ^
horses.cpp:43:35: warning: unused parameter 's' [-Wunused-parameter]
 int get(int l,int r,int v=1,int s=0,int e=n){
                                   ^
horses.cpp:43:43: warning: unused parameter 'e' [-Wunused-parameter]
 int get(int l,int r,int v=1,int s=0,int e=n){
                                           ^
horses.cpp: In function 'int ans()':
horses.cpp:71:25: error: expected unqualified-id before '=' token
     long long ans1=0,ym,=0,mul=mulx;
                         ^
horses.cpp:73:23: error: no matching function for call to 'max(long long int&, int&)'
         ym=max(ym,y[i]);
                       ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from horses.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
horses.cpp:73:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         ym=max(ym,y[i]);
                       ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from horses.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
horses.cpp:73:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         ym=max(ym,y[i]);
                       ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from horses.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
horses.cpp:73:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         ym=max(ym,y[i]);
                       ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from horses.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
horses.cpp:73:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         ym=max(ym,y[i]);
                       ^
horses.cpp:74:23: error: 'mul' was not declared in this scope
         ans1=max(ans1,mul*ym);
                       ^~~
horses.cpp:74:23: note: suggested alternative: 'mulx'
         ans1=max(ans1,mul*ym);
                       ^~~
                       mulx
horses.cpp:77:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return ans1%mod;//(1ll*((mulx*powm(mulm,mod-2))%mod)*ym)%mod;
            ~~~~^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:83:29: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         mulx=(1ll*mulx*x[i])%mod;
              ~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:101:39: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     mulx=(1ll*mulx*powm(x[pos],mod-2))%mod;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:103:27: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     mulx=(1ll*mulx*x[pos])%mod;
          ~~~~~~~~~~~~~~~~~^~~~