Submission #153885

#TimeUsernameProblemLanguageResultExecution timeMemory
153885pit4hHorses (IOI15_horses)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "horses.h" #define ll long long using namespace std; const int mod = 1e9+7, base = (1<<20), N = 5e5+1; ll tree[2*base+1], push[2*base+1], x[N], y[N]; ll fastpow(int a, int b) { if(b==0) { return 1; } int c = fastpow(a, b/2); if(b%2==0) { return (c*c)%mod; } else { return ((c*c)%mod*a)%mod; } } ll inv(int x) { return fastpow(x, mod-2); } void PUSH(int x, ll val) { tree[x]=(tree[x]*val)%mod; push[x]=(push[x]*val)%mod; } int multiply(int id, int L, int R, int l, int r, ll val) { if(L>r || R<r) { return tree[id]; } if(l<=L && r>=R) { tree[id]*=val; push[id]*=val; return tree[id]; } PUSH(id*2, push[id]); PUSH(id*2+1, push[id]); push[id]=1; int M = (L+R)/2; tree[id]=max(multipy(id*2, L, M, l, r, val), multiply(id*2+1, M+1, R, l, r, val)); return tree[id]; } int init(int n, int X[], int Y[]) { for(int i=0; i<n; ++i) { x[i]=X[i]; y[i]=Y[i]; } for(int i=1; i<2*base; ++i) { push[i]=0; } tree[base]=x[i]*y[i]; for(int i=1; i<n; ++i) { tree[i+base]=(((tree[i+base-1]*x[i])%mod)*inv(y[i-1]))%mod; } for(int i=base-1; i>=1; --i) { tree[i]=max(tree[i*2], tree[i*2+1]); } return tree[1]; } int updateX(int pos, ll val) { multiply(1, 0, base-1, pos, base-1, (inv(x[i]) * val)%mod); x[pos]=val; return tree[1]; } int updateY(int pos, ll val) { multiply(1, 0, base-1, pos, pos, (inv(y[i])*val)%mod); y[pos]=val; return tree[1]; }

Compilation message (stderr)

horses.cpp: In function 'long long int fastpow(int, int)':
horses.cpp:11:20: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     int c = fastpow(a, b/2);
             ~~~~~~~^~~~~~~~
horses.cpp: In function 'long long int inv(int)':
horses.cpp:19:13: warning: declaration of 'x' shadows a global declaration [-Wshadow]
 ll inv(int x) {
             ^
horses.cpp:6:36: note: shadowed declaration is here
 ll tree[2*base+1], push[2*base+1], x[N], y[N];
                                    ^
horses.cpp: In function 'void PUSH(int, long long int)':
horses.cpp:22:24: warning: declaration of 'x' shadows a global declaration [-Wshadow]
 void PUSH(int x, ll val) {
                        ^
horses.cpp:6:36: note: shadowed declaration is here
 ll tree[2*base+1], push[2*base+1], x[N], y[N];
                                    ^
horses.cpp: In function 'int multiply(int, int, int, int, int, long long int)':
horses.cpp:28:23: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         return tree[id];
                ~~~~~~~^
horses.cpp:33:23: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         return tree[id];
                ~~~~~~~^
horses.cpp:39:18: error: 'multipy' was not declared in this scope
     tree[id]=max(multipy(id*2, L, M, l, r, val), multiply(id*2+1, M+1, R, l, r, val));
                  ^~~~~~~
horses.cpp:39:18: note: suggested alternative: 'multiply'
     tree[id]=max(multipy(id*2, L, M, l, r, val), multiply(id*2+1, M+1, R, l, r, val));
                  ^~~~~~~
                  multiply
horses.cpp:40:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return tree[id];
            ~~~~~~~^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:50:18: error: 'i' was not declared in this scope
     tree[base]=x[i]*y[i];
                  ^
horses.cpp:51:13: warning: declaration of 'i' shadows a previous local [-Wshadow]
     for(int i=1; i<n; ++i) {
             ^
horses.cpp:50:18: note: shadowed declaration is here
     tree[base]=x[i]*y[i];
                  ^
horses.cpp:52:60: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         tree[i+base]=(((tree[i+base-1]*x[i])%mod)*inv(y[i-1]))%mod;
                                                       ~~~~~^
horses.cpp:54:13: warning: declaration of 'i' shadows a previous local [-Wshadow]
     for(int i=base-1; i>=1; --i) {
             ^
horses.cpp:50:18: note: shadowed declaration is here
     tree[base]=x[i]*y[i];
                  ^
horses.cpp:57:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return tree[1];
         ~~~~~~^
horses.cpp: In function 'int updateX(int, long long int)':
horses.cpp:60:48: error: 'i' was not declared in this scope
     multiply(1, 0, base-1, pos, base-1, (inv(x[i]) * val)%mod);
                                                ^
horses.cpp:62:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return tree[1];
         ~~~~~~^
horses.cpp: In function 'int updateY(int, long long int)':
horses.cpp:65:45: error: 'i' was not declared in this scope
     multiply(1, 0, base-1, pos, pos, (inv(y[i])*val)%mod);
                                             ^
horses.cpp:67:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return tree[1];
         ~~~~~~^