제출 #1157316

#제출 시각아이디문제언어결과실행 시간메모리
1157316InvMOD코끼리 (Dancing Elephants) (IOI11_elephants)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>

#define all(v) (v).begin(), (v).end()

using namespace std;

const int N = 2e5 + 5;

int n, len, a[N];

void init(int N, int L, vector<int> X)
{
    for(int i = 0; i < N; i++){
        a[i + 1] = X[i];
    }
    n = N, len = L;

    return;
}

int update(int ii, int y){
    a[ii + 1] = y;

    vector<int> pos(n + 1);

    for(int i = 1; i <= n; i++)
        pos[i] = a[i];

    sort(1 + all(pos));

    vector<int> dp(n + 1);

    for(int i = 1, j = 1; i <= n; i++){
        while(pos[i] - len > pos[j]) j++;
        dp[i] = dp[j - 1] + 1;
    }

    return dp[n];
}

//#define name "InvMOD"
#ifdef name
int32_t main(){

    freopen(name".INP", "r", stdin);
    freopen(name".OUT", "w", stdout);

    int N, L; cin >> N >> L;

    vector<int> X(N);
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    init(N, L, X);

    int q; cin >> q;
    while(q--){
        int i,y; cin >> i >> y;

        cout << update(i, y) << "\n";
    }
}
#endif // name
/* Test case
Input:
4 10
10 15 17 20

5
2 16
1 25
3 35
0 38
2 0

Output:
1
2
2
2
3
*/

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

/usr/bin/ld: /tmp/ccOqdKw4.o: in function `main':
grader.cpp:(.text.startup+0x27): undefined reference to `init(int, int, int*)'
collect2: error: ld returned 1 exit status