제출 #225544

#제출 시각아이디문제언어결과실행 시간메모리
225544nickmet2004말 (IOI15_horses)C++17
컴파일 에러
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){

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();
}
///int main (){}

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'long long int pow(long long int, long long int)':
horses.cpp:16:21: error: a function-definition is not allowed here before '{' token
 inline ll Inv(ll a) {return pow(a % mod, mod - 2);}
                     ^
horses.cpp:18:68: error: a function-definition is not allowed here before '{' token
 void upd(int idx , int v , int l = 0 , int r = n - 1 , int pos = 1){
                                                                    ^
horses.cpp:27:63: error: a function-definition is not allowed here before '{' token
 int get(int L , int R , int l = 0 , int r= n - 1 , int pos =1){
                                                               ^
horses.cpp:36:37: error: a function-definition is not allowed here before '{' token
 inline bool operator<(div l , div r){return l.a * r.b < r.a * l.b;}
                                     ^
horses.cpp:38:12: error: a function-definition is not allowed here before '{' token
 int solve(){
            ^
horses.cpp:52:36: error: a function-definition is not allowed here before '{' token
 int init(int N , int X[] , int Y[]){
                                    ^
horses.cpp:70:31: error: a function-definition is not allowed here before '{' token
 int updateX(int pos , int val){
                               ^
horses.cpp:77:31: error: a function-definition is not allowed here before '{' token
 int updateY(int pos , int val){
                               ^
horses.cpp:80:1: error: expected '}' at end of input
 }
 ^
horses.cpp:80:1: warning: no return statement in function returning non-void [-Wreturn-type]
horses.cpp:14:11: warning: unused parameter 'a' [-Wunused-parameter]
 ll pow(ll a , ll p){
           ^
horses.cpp:14:18: warning: unused parameter 'p' [-Wunused-parameter]
 ll pow(ll a , ll p){
                  ^