Submission #780872

#TimeUsernameProblemLanguageResultExecution timeMemory
780872NothingXDLast supper (IOI12_supper)C++17
0 / 100
135 ms16612 KiB
#include<bits/stdc++.h>
#include "advisor.h"

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;

void debug_out(){cerr << endl;}

template<typename H, typename... T>
void debug_out(H h, T... t){
	cerr << h << ' ';
	debug_out(t...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e5 + 10;

int n, k, m, res[maxn << 1], lst[maxn];
vector<int> idx[maxn];

void ComputeAdvice(int *C, int N, int K, int M) {
	n = N;
	k = K;
	m = M;
	for (int i = 0; i < n; i++){
		idx[C[i]].push_back(i);
	}
	set<pii> st;
	for (int i = 0; i < n; i++){
		idx[i].push_back(n);
		reverse(all(idx[i]));
		st.insert({idx[i].back(), i});
	}
	memset(lst, -1, sizeof lst);
	for (int i = 0; i < k; i++){
		lst[i] = i;
	}
	for (int i = 0; i < n; i++){
		if (lst[C[i]] != -1){
			st.erase({i, C[i]});
			res[lst[C[i]]] = 1;
		}
		else{
			auto it = st.end();
			it--;
			pii tmp = *it;
			st.erase(it);
			lst[tmp.S] = -1;
		}
		idx[C[i]].pop_back();
		st.insert({idx[C[i]].back(), C[i]});
		lst[C[i]] = k+i;
	}
	for (int i = 0; i < k+n; i++){
		WriteAdvice(res[i]);
	}
}
#include<bits/stdc++.h>
#include "assistant.h"

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;

/*void debug_out(){cerr << endl;}

template<typename H, typename... T>
void debug_out(H h, T... t){
	cerr << h << ' ';
	debug_out(t...);
}*/

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e5 + 10;

bool mark[maxn];

void Assist(unsigned char *A, int N, int K, int R) {
	int n = N;
	int k = K;
	vector<int> del;
	for (int i = 0; i < k; i++){
		mark[i] = true;
		if (A[i] == 0) del.push_back(i);
	}
	for (int i = 0; i < n; i++){
		int tmp = GetRequest();
		if (!mark[tmp]){
			PutBack(del.back());
			mark[del.back()] = false;
			del.pop_back();
		}
		mark[tmp] = true;
		if (A[k+i] == 0) del.push_back(tmp);
	}
}
#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...