Submission #349681

# Submission time Handle Problem Language Result Execution time Memory
349681 2021-01-18T07:19:42 Z amunduzbaev Last supper (IOI12_supper) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#ifndef EVAL
#include "grader.cpp"
#endif
#include "advisor.h"
#include "assistant.h"

using namespace std;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define vii vector<int>	
#define vpii vector<pii>
#define vpll vector<pll>
#define cnt(a)__builtin_popcount(a)
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
 
const int NN = 1e5+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
int fir[NN];
vector<int> used;
void Assist(unsigned char *a, int n, int k, int r) {
	int last = 0;
	
	used.assign(n, 0);
	vector<int> cur(k);
	for(int i=0;i<k;i++) cur[i] = i, used[i] =1;
	
	for(int i=0;i<n;i++){
		//for(auto x:cur) cout<<x<<" ";
		//cout<<"\n";
		
		int nw = GetRequest();
		if(a[last]) { last++;  continue; }
		last++;
		
		int l = 0, r = k-1;
		while(l < r){
			int m = (l + r +1)>>1;
			//cout<<l<<" "<<r<<"\n";
			if((int)a[last]) r = m-1;
			else l = m;
			//cout<<(int)a[last]<<"\n";
			last++;
		}
		//cout<<l<<" "<<r<<"\n";
		PutBack(cur[l]);
		cur[l] = nw;
	}
}

vector<int> tmp[NN];

void ComputeAdvice(int *c, int n, int k, int m){
	used.assign(n, mod);
	for(int i=n-1;i>=0;i--){
		used[c[i]] = i;
		tmp[i] = used;
	}
	
	vector<int> tt, cur;
	used.assign(n, 0);
	for(int i=0;i<k;i++) { used[i] = 1; tt.pb(i); }
	
	
	for(int i=0;i<n;i++){
 		cur = tmp[i];
		if(used[c[i]]) { WriteAdvice(1); continue; }
		else WriteAdvice(0);
 		
		int l = 0, r = k-1;
		int need = tt[0], in = 0;
		
		for(int j=0;j<sz(tt);j++) if(cur[tt[j]] > cur[need]) need = tt[j], in = j;
		//cout<<in<<"\n";
		//for(auto x:tt) cout<<x<<" ";
		//cout<<"\n";
		
		while(l < r){
			int m = (l + r +1)>>1;
			//cout<<l<<" "<<m<<" "<<r<<"\n";
			if(m <= in) { WriteAdvice(0); l = m; }
			else { WriteAdvice(1); r = m-1; }
		}
		used[c[i]] = 1;
		used[tt[in]] = 0;
		tt[in] = c[i];
		//ss.insert({a[c[i]], c[i]});
	}
	//cout<<"\n";
}

/*

4 2 12
2 0 3 0

7 2 14
1 1 2 3 1 3 2

*/
#include <bits/stdc++.h>

#ifndef EVAL
#include "grader.cpp"
#endif
#include "advisor.h"
#include "assistant.h"

using namespace std;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define vii vector<int>	
#define vpii vector<pii>
#define vpll vector<pll>
#define cnt(a)__builtin_popcount(a)
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
 
const int NN = 1e5+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
int fir[NN];
vector<int> used;
void Assist(unsigned char *a, int n, int k, int r) {
	int last = 0;
	
	used.assign(n, 0);
	vector<int> cur(k);
	for(int i=0;i<k;i++) cur[i] = i, used[i] =1;
	
	for(int i=0;i<n;i++){
		//for(auto x:cur) cout<<x<<" ";
		//cout<<"\n";
		
		int nw = GetRequest();
		if(a[last]) { last++;  continue; }
		last++;
		
		int l = 0, r = k-1;
		while(l < r){
			int m = (l + r +1)>>1;
			//cout<<l<<" "<<r<<"\n";
			if((int)a[last]) r = m-1;
			else l = m;
			//cout<<(int)a[last]<<"\n";
			last++;
		}
		//cout<<l<<" "<<r<<"\n";
		PutBack(cur[l]);
		cur[l] = nw;
	}
}

vector<int> tmp[NN];

void ComputeAdvice(int *c, int n, int k, int m){
	used.assign(n, mod);
	for(int i=n-1;i>=0;i--){
		used[c[i]] = i;
		tmp[i] = used;
	}
	
	vector<int> tt, cur;
	used.assign(n, 0);
	for(int i=0;i<k;i++) { used[i] = 1; tt.pb(i); }
	
	
	for(int i=0;i<n;i++){
 		cur = tmp[i];
		if(used[c[i]]) { WriteAdvice(1); continue; }
		else WriteAdvice(0);
 		
		int l = 0, r = k-1;
		int need = tt[0], in = 0;
		
		for(int j=0;j<sz(tt);j++) if(cur[tt[j]] > cur[need]) need = tt[j], in = j;
		//cout<<in<<"\n";
		//for(auto x:tt) cout<<x<<" ";
		//cout<<"\n";
		
		while(l < r){
			int m = (l + r +1)>>1;
			//cout<<l<<" "<<m<<" "<<r<<"\n";
			if(m <= in) { WriteAdvice(0); l = m; }
			else { WriteAdvice(1); r = m-1; }
		}
		used[c[i]] = 1;
		used[tt[in]] = 0;
		tt[in] = c[i];
		//ss.insert({a[c[i]], c[i]});
	}
	//cout<<"\n";
}

/*

4 2 12
2 0 3 0

7 2 14
1 1 2 3 1 3 2

*/

Compilation message

/tmp/cc6nPj5p.o: In function `Assist(unsigned char*, int, int, int)':
advisor.cpp:(.text+0x12e): undefined reference to `GetRequest()'
advisor.cpp:(.text+0x18f): undefined reference to `PutBack(int)'
collect2: error: ld returned 1 exit status

/tmp/ccUlBNjI.o: In function `ComputeAdvice(int*, int, int, int)':
assistant.cpp:(.text+0x406): undefined reference to `WriteAdvice(unsigned char)'
assistant.cpp:(.text+0x442): undefined reference to `WriteAdvice(unsigned char)'
assistant.cpp:(.text+0x4b3): undefined reference to `WriteAdvice(unsigned char)'
assistant.cpp:(.text+0x4d1): undefined reference to `WriteAdvice(unsigned char)'
collect2: error: ld returned 1 exit status