답안 #941611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941611 2024-03-09T07:56:14 Z wii 코끼리 (Dancing Elephants) (IOI11_elephants) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef double db;
typedef long long ll;
typedef long double ld;
 
#define int ll
typedef pair<int, int> pii;
 
#define lx (id << 1)
#define rx (lx | 1)
#define gcd __gcd
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define bit(i, mask) ((mask) >> (i) & 1)
#define reset(x, val) memset(x, val, sizeof(x))
#define foru(i,a,b) for(int i = (a); i <= (b); ++i)
#define ford(i,a,b) for(int i = (a); i >= (b); --i)
#define FastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
template<typename T> bool maximize(T &res, const T &val) { if (res < val) { res = val; return true; } return false; }
template<typename T> bool minimize(T &res, const T &val) { if (val < res) { res = val; return true; } return false; }
 
const ll Linf = 0x3f3f3f3f3f3f3f3f;
const int Inf = 0x3f3f3f3f;
const ll Mod = 1e9 + 7;
const ll Mod2 = ll(1e9) + 9;
const int Lim = 1e6 + 5;
const int inv6 = 166666668;
 
/// ====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====
 
const int base = 3;
const int MaxN = 2e5 + 5;
const int dx[] = {+1, -1, 0, 0};
const int dy[] = {0, 0, +1, -1};
const int block_size = sqrt(2e9) + 2;
 
int n, len;
int val[MaxN];
int order[MaxN];

void init(int N, int L, vector<int> x);
int update(int i, int y);
 
void init(int N, int L, vector<int> x) {
    n = N;
    len = L;
 
    for (int i = 0; i < N; ++i)
        val[i] = x[i];
 
    for (int i = 0; i < N; ++i)
        order[i] = val[i];
 
    sort(order, order + N);
}
 
int update(int i, int y) {
    int t = val[i];
    for (int i = 0; i < n; ++i) if (order[i] == t) {
        for (int j = i; j < n; ++j)
            order[j] = order[j + 1];
    }
 
    order[n - 1] = y;
    for (int i = n - 1; i > 0; --i)
        if (order[i] < order[i - 1])
            swap(order[i], order[i - 1]);
 
    int res = 0, lf = -Linf;
    for (int i = 0; i < n; ++i) {
        if (lf + len < order[i])
            ++res, lf = order[i];
    }
 
    val[i] = y;
    return res;
}

Compilation message

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