Submission #96429

#TimeUsernameProblemLanguageResultExecution timeMemory
96429figter001Horses (IOI15_horses)C++14
Compilation error
0 ms0 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int maxn = 5e5 + 50; const int mod = 1e9+7; pair<ld,int> lgs[(1<<20)]; ld sum[maxn],lazy1[(1<<20)],val1; ll seg[(1<<20)],y[maxn],x[maxn],val2; int n,l,r; ll Pow(ll a,ll b){ if(!b)return 1; ll ret = Pow(a,b/2); if(b%2)return ((ret*ret)%mod*a)%mod; return (ret&ret)%mod; } void build1(int n,int s,int e){ if(s == e){ lgs[n] = {sum[s] + log((ld)y[s]),s}; return; } build1(n*2,s,(s+e)/2); build1(n*2+1,(s+e)/2+1,e); lgs[n] = max(lgs[n*2],lgs[n*2+1]); } void build2(int n,int s,int e){ if(s == e){ seg[n] = x[s]; return; } build2(n*2,s,(s+e)/2); build2(n*2+1,(s+e)/2+1,e); seg[n] = (seg[n*2] * seg[n*2+1])%mod; } void update1(int n,int s,int e){ if(s > r || e < l)return; if(s >= l && e <= r){ lazy1[n] += val1; pro1(n,s,e); return; } update1(n*2,s,(s+e)/2); update1(n*2+1,(s+e)/2+1,e); lgs[n] = max(lgs[n*2],lgs[n*2+1]); } void update2(int n,int s,int e){ if(s > r || e < l)return; if(s >= l && e <= r){ seg[n] = val; return; } update2(n*2,s,(s+e)/2); update2(n*2+1,(s+e)/2+1,e); seg[n] = (seg[n*2] * seg[n*2+1])%mod; } int get(int n,int s,int e){ pro2(n,s,e); if(s > r || e < l)return 1; if(s >= l && e <= r)return (int)seg[n]; return get(n*2,s,(s+e)/2) * get(n*2+1,(s+e)/2+1,e); } int solve(){ l = 1; r = lgs[1].second; return (get(1,1,n) * y[r])%mod; } int init(int N, int X[], int Y[]){ n = N; for(int i=1;i<=n;i++){ y[i] = Y[i-1]; x[i] = X[i-1]; sum[i] = sum[i-1] + log((ld)x[i]); } build1(1,1,n); build2(1,1,n); return solve(); } int updateX(int pos, int val) { pos++; val1 = log((ld)val) - log((ld)x[pos]); val2 = val; x[pos] = val; l = pos; r = n;h update1(1,1,n); l = r = pos; update2(1,1,n); return solve(); } int updateY(int pos, int val) { pos++; val1 = log((ld)val) - log((ld)y[pos]); y[pos] = val; l = r = pos; update1(1,1,n); return solve(); }

Compilation message (stderr)

horses.cpp: In function 'void build1(int, int, int)':
horses.cpp:23:30: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 void build1(int n,int s,int e){
                              ^
horses.cpp:14:5: note: shadowed declaration is here
 int n,l,r;
     ^
horses.cpp: In function 'void build2(int, int, int)':
horses.cpp:33:30: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 void build2(int n,int s,int e){
                              ^
horses.cpp:14:5: note: shadowed declaration is here
 int n,l,r;
     ^
horses.cpp: In function 'void update1(int, int, int)':
horses.cpp:43:31: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 void update1(int n,int s,int e){
                               ^
horses.cpp:14:5: note: shadowed declaration is here
 int n,l,r;
     ^
horses.cpp:47:3: error: 'pro1' was not declared in this scope
   pro1(n,s,e);
   ^~~~
horses.cpp:47:3: note: suggested alternative: 'pow'
   pro1(n,s,e);
   ^~~~
   pow
horses.cpp: In function 'void update2(int, int, int)':
horses.cpp:55:31: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 void update2(int n,int s,int e){
                               ^
horses.cpp:14:5: note: shadowed declaration is here
 int n,l,r;
     ^
horses.cpp:58:12: error: 'val' was not declared in this scope
   seg[n] = val;
            ^~~
horses.cpp:58:12: note: suggested alternative: 'val2'
   seg[n] = val;
            ^~~
            val2
horses.cpp: In function 'int get(int, int, int)':
horses.cpp:66:26: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 int get(int n,int s,int e){
                          ^
horses.cpp:14:5: note: shadowed declaration is here
 int n,l,r;
     ^
horses.cpp:67:2: error: 'pro2' was not declared in this scope
  pro2(n,s,e);
  ^~~~
horses.cpp:67:2: note: suggested alternative: 'pow'
  pro2(n,s,e);
  ^~~~
  pow
horses.cpp: In function 'int solve()':
horses.cpp:76:28: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return (get(1,1,n) * y[r])%mod;
         ~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:97:8: error: 'h' was not declared in this scope
  r = n;h
        ^