답안 #993819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993819 2024-06-06T13:05:12 Z midi 코끼리 (Dancing Elephants) (IOI11_elephants) C++17
컴파일 오류
0 ms 0 KB
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define vc vector
typedef vc<ll> vcll;
typedef vc<bool> vcb;
#define pr pair
typedef pr<ll, ll> prll;
typedef set<ll> setll;
typedef map<ll,ll> mapll;
#define uset unordered_set
typedef uset<ll> usetll;
#define umap unordered_map
typedef umap<ll,ll> umapll;

#define f0r(i,a,n) for ((i)=(a); (i)<=(n); (i)++)
#define r0f(i,n,a) for ((i)=(n); (i)>=(a); (i)--)

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define fi first
#define se second
#define sz size
#define all(x) (x).begin(), (x).end()
#define all0(x, n) (x).begin(), (x).begin()+n
#define all1(x, n) (x).begin()+1, (x).begin()+n+1
#define allrev(x) (x).rbegin(), (x).rend()
#define in(v, s) ((s).find((v)) != (s).end())
#define GCD(x, y) __gcd(abs((x)), abs((y)))

#define INF (LLONG_MAX>>3ll)
#define MOD (1'000'000'007ll)

#define mxN (150'010ll)

inline void maxa(ll &a, ll b) { if (a<b) a=b; }
inline void mina(ll &a, ll b) { if (a>b) a=b; }

inline void print (vcll &a, ll n=-1, string name="")
{
	cout << name << ": ";
	if (n==-1) for (ll x:a) printf("%lli ", x);
	else
	{
		ll i;
		f0r(i,1,n) printf("%lli ", a[i]);
	}
	printf("\n");
}

ll n, L;
vcll ar(mxN);
mapll nums;

inline void del (ll x) { if ((--nums[x]) == 0) nums.erase(x); }
inline void ins (ll x)
{
	if (in(x,nums)) nums[x]++;
	else nums[x]=1;
}

inline ll calc()
{
	ll c=0, last=-INF;
	for (prll xc:nums)
	{
		ll x=xc.fi;
		if (x-last > L)
		{
			last=x;
			c++;
		}
	}
	return c;
}

inline void init (ll N, ll l, vcll X)
{
	n=N; L=l;
	ll i;
	f0r(i,0,n-1) ins(ar[i+1] = X[i]);
}

inline ll update (ll i, ll x)
{
	i++;
	del(ar[i]);
	ins(ar[i]=x);
	return calc();
}

Compilation message

/usr/bin/ld: /tmp/cc9KdOCD.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