제출 #152808

#제출 시각아이디문제언어결과실행 시간메모리
152808qkxwsm최후의 만찬 (IOI12_supper)C++14
0 / 100
401 ms15532 KiB
#include "advisor.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;



void ComputeAdvice(int *C, int N, int K, int M)
{
	//ugh lol ok lets brute force.
	int B = 32 - __builtin_clz(K);
	FOR(i, 0, N)
	{
		FORD(j, B, 0)
		{
			WriteAdvice((C[i] & (1 << j)) ? 1 : 0);
		}
	}
}
#include "assistant.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 100013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

set<pii> alive;
int arr[MAXN];
int rt[MAXN], pos[MAXN];

void Assist(unsigned char *A, int N, int K, int R)
{
	int B = 32 - __builtin_clz(K);
	FOR(i, 0, N)
	{
		int num = 0;
		FOR(j, i * B, (i + 1) * B)
		{
			num *= 2; if (A[j]) num++;
		}
		arr[i] = num;
		// cerr << "arr " << i << " = " << num << endl;
	}
	FOR(i, 0, N)
	{
		pos[i] = N;
	}
	FORD(i, N, 0)
	{
		// cerr << "pos " << arr[i] << " set to " << i << endl;
		rt[i] = pos[arr[i]];
		pos[arr[i]] = i;
	}
	// FOR(i, 0, N)
	// {
	// 	cerr << pos[i] << ' ';
	// }
	// cerr << endl;
	FOR(i, 0, K)
	{
		// cerr << pos[i] << ' ';
		alive.insert({pos[i], i});
	}
	// cerr << endl;
	FOR(i, 0, N)
	{
		int cur = GetRequest();
		if (alive.find({pos[cur], cur}) == alive.end())
		{
			pii p = *alive.rbegin();
			alive.erase(prev(alive.end()));
			PutBack(p.se);
			alive.insert({pos[cur], cur});
		}
		alive.erase({pos[cur], cur});
		pos[cur] = rt[i];
		alive.insert({pos[cur], cur});
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...