Submission #133587

#TimeUsernameProblemLanguageResultExecution timeMemory
133587ckodserHorses (IOI15_horses)C++14
0 / 100
410 ms40436 KiB
#include "horses.h" #include<bits/stdc++.h> #define ll long long #define pb push_back #define ld long double #define mp make_pair #define F first #define S second #define pii pair<ll,ll> using namespace :: std; const ll maxn=5e5+500; const ll inf=1e9+6; const ll mod=1e9+7; ll y[maxn]; void bild(ll l,ll r,ll node){ } void update(ll l,ll r,ll node,ll pos){ } ll findMx(ll l,ll r,ll L,ll R,ll node){ ll ans=0; for(ll i=l;i<r;i++){ ans=max(ans,y[i]); } return ans; } set<ll> st; ll x[maxn]; ll rx[maxn]; ll n,Z; ll poww(ll a,ll b){ ll ans=1; while(b){ if(b&1){ ans=(ans*a)%mod; } b>>=1; a=(a*a)%mod; } return ans; } ll findAns(){ vector<pii> vec; auto it=st.end(); ll zarb=1; ll last=n; while(it!=st.begin()){ it--; zarb*=x[*it]; if(zarb>inf){ break; } vec.pb(mp(*it,findMx(*it,last,0,n,1))); last=*it; } reverse(vec.begin(),vec.end()); ll t=Z; for(auto r:vec){ t=(t*rx[r.F])%mod; } zarb=1; pii ans=mp(0,0); for(auto r:vec){ zarb*=x[r.F]; ans=max(ans,mp(zarb*r.S,(((t*x[r.F])%mod)*r.S)%mod)); } return ans.S; } int init(int N, int X[], int Y[]){ n=N; Z=1; for(ll i=0;i<n;i++){ x[i]=X[i]; Z=(Z*X[i])%mod; rx[i]=poww(x[i],mod-2); y[i]=Y[i]; if(x[i]!=1)st.insert(i); } bild(0,n,1); return findAns(); } int updateX(int pos, int val) { Z*=rx[pos]; Z%=mod; if(x[pos]!=1 && val==1){ st.erase(pos); } if(x[pos]==1 && val!=1){ st.insert(pos); } x[pos]=val; Z*=val; Z%=mod; rx[pos]=poww(x[pos],mod-2); return findAns(); } int updateY(int pos, int val){ y[pos]=val; update(0,n,1,pos); return findAns(); }

Compilation message (stderr)

horses.cpp: In function 'void bild(long long int, long long int, long long int)':
horses.cpp:20:14: warning: unused parameter 'l' [-Wunused-parameter]
 void bild(ll l,ll r,ll node){
              ^
horses.cpp:20:19: warning: unused parameter 'r' [-Wunused-parameter]
 void bild(ll l,ll r,ll node){
                   ^
horses.cpp:20:24: warning: unused parameter 'node' [-Wunused-parameter]
 void bild(ll l,ll r,ll node){
                        ^~~~
horses.cpp: In function 'void update(long long int, long long int, long long int, long long int)':
horses.cpp:23:16: warning: unused parameter 'l' [-Wunused-parameter]
 void update(ll l,ll r,ll node,ll pos){
                ^
horses.cpp:23:21: warning: unused parameter 'r' [-Wunused-parameter]
 void update(ll l,ll r,ll node,ll pos){
                     ^
horses.cpp:23:26: warning: unused parameter 'node' [-Wunused-parameter]
 void update(ll l,ll r,ll node,ll pos){
                          ^~~~
horses.cpp:23:34: warning: unused parameter 'pos' [-Wunused-parameter]
 void update(ll l,ll r,ll node,ll pos){
                                  ^~~
horses.cpp: In function 'long long int findMx(long long int, long long int, long long int, long long int, long long int)':
horses.cpp:26:24: warning: unused parameter 'L' [-Wunused-parameter]
 ll findMx(ll l,ll r,ll L,ll R,ll node){
                        ^
horses.cpp:26:29: warning: unused parameter 'R' [-Wunused-parameter]
 ll findMx(ll l,ll r,ll L,ll R,ll node){
                             ^
horses.cpp:26:34: warning: unused parameter 'node' [-Wunused-parameter]
 ll findMx(ll l,ll r,ll L,ll R,ll node){
                                  ^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:87:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return findAns();
            ~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:102:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return findAns();
            ~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:107:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return findAns();
            ~~~~~~~^~
#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...