Submission #50127

# Submission time Handle Problem Language Result Execution time Memory
50127 2018-06-07T16:45:15 Z Benq Last supper (IOI12_supper) C++14
Compilation error
0 ms 0 KB
#include "advisor.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

queue<int> use[100000];
Tree<int> cur;
int nex[100000], res;
set<pi> nexUse;

/*unsigned char* A = new unsigned char[100];
int z = 0;

void WriteAdvice(int x) {
    A[z++] = x;
    cout << x << "\n";
}

void send(int x) {
	F0Rd(i,res) {
		if (x&(1<<i)) WriteAdvice(1);
		else WriteAdvice(0);
	}
}*/

int getBits(int x) {
	if (x == 1) return 0;
	return 32-__builtin_clz(x-1);
}

void ComputeAdvice(int *C, int N, int K, int M) {
	res = getBits(N);
	F0R(i,N) use[C[i]].push(i);
	F0R(i,N) {
	    nex[i] = MOD;
	    if (sz(use[i])) nex[i] = use[i].front();
	}
	F0R(i,K) {
		cur.insert(i);
		nexUse.insert({nex[i],i});
	}
	F0R(i,N) {
		if (cur.find(C[i]) == cur.end()) {
			auto a = *nexUse.rbegin();
			send(cur.order_of_key(a.s));
			cur.erase(a.s); nexUse.erase(a); 
			cur.insert(C[i]); nexUse.insert({nex[C[i]],C[i]});
		}
		nexUse.erase({nex[C[i]],C[i]});
		use[C[i]].pop();
		if (sz(use[C[i]])) nex[C[i]] = use[C[i]].front();
		else nex[C[i]] = MOD;
		nexUse.insert({nex[C[i]],C[i]});
	}

}
#include "assistant.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

Tree<int> S;
int ind = 0;
int res;

int getBits(int x) {
	if (x == 1) return 0;
	return 32-__builtin_clz(x-1);
}

int getNex(unsigned char *A) {
	int t = 0;
	F0Rd(i,res) {
		int x = A[ind++];
		if (x) t ^= 1<<i;
	}
	return t;
}

/*int RES[4] = {2,0,3,0};
int Z = 0;

int GetRequest() { return RES[Z++]; }
void PutBack(int x) { cout << "HI " << x << "\n"; }*/

void Assist(unsigned char *A, int N, int K, int R) {
	res = getBits(N);
	F0R(i,K) S.insert(i);
	F0R(i,N) {
		int req = GetRequest();
		if (S.find(req) == S.end()) {
			int x = *S.find_by_order(getNex(A));
			S.erase(x);
			S.insert(req);
			PutBack(x);
		}
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:84:4: error: 'send' was not declared in this scope
    send(cur.order_of_key(a.s));
    ^~~~
advisor.cpp:84:4: note: suggested alternative: 'setns'
    send(cur.order_of_key(a.s));
    ^~~~
    setns