Submission #225545

#TimeUsernameProblemLanguageResultExecution timeMemory
225545nickmet2004말 (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include "horses.h" #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]; ll pow(ll a , ll p){ ll res = 0; a %= mod; while(p){ if(p & 1) res = (res * a) % mod; a = (a * a) % mod; p /= 2; }return res; } inline ll Inv(ll a) {return pow(a % mod, mod - 2);} void upd(int idx , int v , int l = 0 , int r = n - 1 , int pos = 1){ if(l == r){ T[pos] = v;return; } int mid = (l + r) >> 1; if(idx <= mid) upd(idx , v , l , mid , pos * 2); else upd(idx , v , mid + 1 , r , pos * 2 + 1); T[pos] = max(T[pos* 2] , T[pos *2 + 1]); } int get(int L , int R , int l = 0 , int r= n - 1 , int pos =1){ 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) , get(L , R , mid + 1 , r , pos * 2 + 1)); } struct div{ ll a , b; }; inline bool operator<(div l , div r){return l.a * r.b < r.a * l.b;} int solve(){ div mx{0 , 1}; ll curxmult = 1; /// (y / curxmult) has to be as large as possible for(auto it = poss.rbegin(); it != poss.rend() && curxmult < 1000000000LL; ++it){ int i = *it; int j = (it == poss.rbegin() ? n : *prev(it)); mx = max(mx , {get(i , j - 1) , curxmult}); curxmult *= x[i]; } ll res = (mx.a * Inv(mx.b)) % mod; return res = (res * xmult) % mod; } int 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]); } poss.clear(); 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(pos && x[pos] > 1 && val == 1) poss.erase(pos); if(pos && 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(); }

Compilation message (stderr)

horses.cpp: In function 'long long int Inv(long long int)':
horses.cpp:23:32: warning: conversion to 'long long int' from '__gnu_cxx::__promote_2<long long int, int, double, double>::__type {aka double}' may alter its value [-Wfloat-conversion]
 inline ll Inv(ll a) {return pow(a % mod, mod - 2);}
                             ~~~^~~~~~~~~~~~~~~~~~
horses.cpp: At global scope:
horses.cpp:43:23: error: declaration of 'operator<' as non-function
 inline bool operator<(div l , div r){return l.a * r.b < r.a * l.b;}
                       ^~~
horses.cpp:43:27: error: expected ')' before 'l'
 inline bool operator<(div l , div r){return l.a * r.b < r.a * l.b;}
                           ^
horses.cpp:43:35: error: expected ')' before 'r'
 inline bool operator<(div l , div r){return l.a * r.b < r.a * l.b;}
                                   ^
horses.cpp: In function 'int solve()':
horses.cpp:46:9: error: expected ';' before 'mx'
     div mx{0 , 1};
         ^~
horses.cpp:46:18: error: statement cannot resolve address of overloaded function
     div mx{0 , 1};
                  ^
horses.cpp:52:9: error: 'mx' was not declared in this scope
         mx = max(mx , {get(i , j - 1) , curxmult});
         ^~
horses.cpp:52:9: note: suggested alternative: 'x'
         mx = max(mx , {get(i , j - 1) , curxmult});
         ^~
         x
horses.cpp:55:15: error: 'mx' was not declared in this scope
     ll res = (mx.a * Inv(mx.b)) % mod;
               ^~
horses.cpp:55:15: note: suggested alternative: 'x'
     ll res = (mx.a * Inv(mx.b)) % mod;
               ^~
               x
horses.cpp:56:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return res = (res * xmult) % mod;
            ~~~~^~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:59:35: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 int init(int N , int X[] , int Y[]){
                                   ^
horses.cpp:6:11: note: shadowed declaration is here
 const int N = 5e5 + 5 , mod = 1e9 + 7;
           ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:80:35: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     xmult = (xmult * Inv(x[pos])) % mod;
             ~~~~~~~~~~~~~~~~~~~~~~^~~~~