제출 #1016312

#제출 시각아이디문제언어결과실행 시간메모리
1016312ayankarimova말 (IOI15_horses)C++14
컴파일 에러
0 ms0 KiB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll mod=1e9+7;
const ll sz=5e+5;
struct d
{
    double sum, lpre;
    ll mul, pre;
};
d st[sz*4];
ll x[sz], y[sz], n;
double xl[sz], yl[sz];
d make(ll pos)
{
    d cur;
    cur.sum=xl[pos];
    cur.mul=x[pos];
    cur.lpre=xl[pos]+yl[pos];
    cur.pre=(x[pos]*y[pos])%mod;
    return cur;
}
void mrg(d a, d b, d &c)
{
    c.sum=a.sum+b.sum;
    c.mul=(a.mul*b.mul)%mod;
    if(a.lpre>a.sum+b.lpre){
        c.lpre=a.lpre;
        c.pre=a.pre;
    }
    else{
        c.lpre=a.sum+b.lpre;
        c.pre=(a.mul*b.pre)%mod;
    }
}
void build(ll l, ll r, ll in)
{
    if(l==r){
        st[in]=make(l);
        return;
    }
    ll mid=(l+r)/2;
    build(l, mid, in*2);
    build(mid+1, r, in*2+1);
    mrg(st[in*2], st[in*2+1], st[in]);
}
void update(ll l, ll r, ll in, ll pos)
{
    if(l==r){
        st[in]=make(l);
        return;
    }
    ll mid=(l+r)/2;
    if(pos<=mid){
        update(l, mid, in*2, pos);
    }
    else{
        update(mid+1, r, in*2+1, pos);
    }
    mrg(st[in*2], st[in*2+1], st[in]);
}
ll init(int N, int X[], int Y[]) {

    ll num=1, ans=0;
    n=N;
    for(int i=0; i<n; i++){
        x[i+1]=(X[i]);
        y[i+1]=(Y[i]);
        xl[i+1]=log10(X[i]);
        yl[i+1]=log10(Y[i]);
    }
    build(1, n, 1);
	return st[1].pre;
}
ll updateX(int pos, int val) {

    pos++;
    x[pos]=val;
    xl[pos]=log10(val);
    update(1, n, 1, pos);
	return st[1].pre;
}
ll updateY(int pos, int val) {

	pos++;
    y[pos]=val;
    yl[pos]=log10(val);
    update(1, n, 1, pos);
	return st[1].pre;
}

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

horses.cpp:64:4: error: ambiguating new declaration of 'long long int init(int, int*, int*)'
   64 | ll init(int N, int X[], int Y[]) {
      |    ^~~~
In file included from horses.cpp:1:
horses.h:4:5: note: old declaration 'int init(int, int*, int*)'
    4 | int init(int N, int X[], int Y[]);
      |     ^~~~
horses.cpp: In function 'long long int init(int, int*, int*)':
horses.cpp:66:8: warning: unused variable 'num' [-Wunused-variable]
   66 |     ll num=1, ans=0;
      |        ^~~
horses.cpp:66:15: warning: unused variable 'ans' [-Wunused-variable]
   66 |     ll num=1, ans=0;
      |               ^~~
horses.cpp: At global scope:
horses.cpp:77:4: error: ambiguating new declaration of 'long long int updateX(int, int)'
   77 | ll updateX(int pos, int val) {
      |    ^~~~~~~
In file included from horses.cpp:1:
horses.h:5:5: note: old declaration 'int updateX(int, int)'
    5 | int updateX(int pos, int val);
      |     ^~~~~~~
horses.cpp:85:4: error: ambiguating new declaration of 'long long int updateY(int, int)'
   85 | ll updateY(int pos, int val) {
      |    ^~~~~~~
In file included from horses.cpp:1:
horses.h:6:5: note: old declaration 'int updateY(int, int)'
    6 | int updateY(int pos, int val);
      |     ^~~~~~~