Submission #225531

#TimeUsernameProblemLanguageResultExecution timeMemory
225531nickmet2004말 (IOI15_horses)C++11
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; const int N = 5e5 + 5 , mod = 1e9 + 7; int n; vector<int> x , y; int xmult; set<int> poss; int T[1 << 20]; int pow(int a , int p){ ll res = 0; a %= mod; while(p){ if(p & 1) res = (res * a) % mod; a = (a * a) % mod; p /= 2; }return res; } inline int Inv(int a) {return pow(a % mod, mod - 2);} void upd(int idx , int v , int l = 0 , int r = n - 1 , int pos = 0){ if(l == r){ T[pos] = v;return; } int mid = (l + r) >> 1; if(l <= idx && idx <= mid) upd(idx , v , l , mid , pos * 2 + 1); if(mid < idx && idx <= r) upd(idx , v , mid + 1 , r , pos * 2 + 2); T[pos] = max(T[pos + pos + 1] , T[pos + pos + 2]); } int get(int L , int R , int l = 0 , int r= n - 1 , int pos = 0){ if(r < L || R < l) return INT_MIN; if(L <= l && r <= R) return T[pos]; int mid = (l + r) >> 1; return max(get(L , R , l , mid , pos * 2 + 1) , get(L , R , mid + 1 , r , pos * 2 + 2)); } struct div{ ll a , b; bool operator<(const div &A) const { return a * A.b < b * A.a; } }mx; int solve(){ mx.a = 0 , mx.b = 1; ll curxmult = 1; /// (y / curxmult) has to be as large as possible for(auto it = poss.rbegin(); it != poss.rend() && curxmult < 1000000000; ++it){ int i = *it; int j = (it == poss.rbegin()) ? n : *prev(it); mx = max(mx , {get(i , j - 1) , curxmult}); curxmult *= x[i]; } int res = (mx.a * Inv(mx.b)) % mod; return res = (res * xmult) % mod; } void init(int N , int X[] , int Y[]){ n = N; x.assign(X , X + N); y.assign(Y , Y + N); for(int i = 0; i < n; ++i){ upd(i , y[i]); } xmult = 1; poss.insert(0); for(int i = 0; i < n; ++i){ if(x[i] > 1){ poss.insert(i); xmult = (xmult * x[i]) % mod; } } return solve(); } int updateX(int pos , int val){ if(x[pos] > 1 && val == 1) poss.erase(pos); if(x[pos] == 1 && val > 1) poss.insert(pos); xmult = (xmult * Inv(x[pos])) % mod; xmult = (xmult * (x[pos] = val)) % mod; return solve(); } int updateY(int pos , int val){ upd(pos , y[pos] = val); return solve(); } ///int main (){}

Compilation message (stderr)

horses.cpp: In function 'int pow(int, int)':
horses.cpp:16:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(p & 1) res = (res * a) % mod; a = (a * a) % mod;
         ^~
horses.cpp:16:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         if(p & 1) res = (res * a) % mod; a = (a * a) % mod;
                                          ^
horses.cpp:18:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     }return res;
             ^~~
horses.cpp: In function 'int solve()':
horses.cpp:54:30: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     int res = (mx.a * Inv(mx.b)) % mod;
                           ~~~^
horses.cpp:54:34: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     int res = (mx.a * Inv(mx.b)) % mod;
               ~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'void init(int, int*, int*)':
horses.cpp:58:36: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 void init(int N , int X[] , int Y[]){
                                    ^
horses.cpp:5:11: note: shadowed declaration is here
 const int N = 5e5 + 5 , mod = 1e9 + 7;
           ^
horses.cpp:73:18: error: return-statement with a value, in function returning 'void' [-fpermissive]
     return solve();
                  ^