Submission #241735

# Submission time Handle Problem Language Result Execution time Memory
241735 2020-06-25T12:00:16 Z kshitij_sodani Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second

#include "advisor.h"
void WriteAdvice(int x);
vector<int> ind[1000001];
int ans[2000001];
set<int> cur;
/*void WriteAdvice(int x){
	cout<<x<<endl;
}*/
void WriteAdvice(int x);

void ComputeAdvice(int c[], int n, int k, int m) {
	set<pair<int,int>> kk;
	for(int i=0;i<n;i++){
		ind[c[i]].pb(i);
	}
	for(int i=0;i<n;i++){
		ind[i].pb(n+1);
	}
	for(int i=0;i<k;i++){
		kk.insert({ind[i][0],i});
		cur.insert(i);
	}

	for(int i=0;i<n;i++){
		if(cur.find(c[i])!=cur.end()){
			kk.erase({i,c[i]});
			int j=upper_bound(ind[c[i]].begin(),ind[c[i]].end(),i)-ind[c[i]].begin();
			kk.insert({ind[c[i]][j],i+k});
			continue;
		}
		auto j=kk.end();
		j--;
		ans[(*j).b]=1;
		if((*j).b>=k){
			cur.erase(c[(*j).b-k]);
		}
		else{
			cur.erase((*j).b);
		}
		cur.insert(c[i]);
		kk.erase(j);
		int jj=upper_bound(ind[c[i]].begin(),ind[c[i]].end(),i)-ind[c[i]].begin();
		kk.insert({ind[c[i]][jj],i+k});
	}

	for(int i=0;i<n+k;i++){
		WriteAdvice(ans[i]);
	}

 //	WriteAdvice(0);
}
/*int main(){
	int cc[4];
	cc[0]=2;
	cc[1]=0;
	cc[2]=3;
	cc[3]=0;

	ComputeAdvice(cc,4,2,1000);
	return 0;
}

*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second

#include "assistant.h"
int arr[100001];
set<int> cur3;
set<int> cur4;
int ind3=0;
unsigned char aa[2000001];
int rr;
void PutBack(int x);
int GetRequest();

/*int read(){
	int ans=0;

	for(int i=0;i<15;i++){
		if(aa[ind3+i]=='1'){
			ans+=(1<<i);
		}
	}
	ind3+=15;
	return ans;
}
int GetRequest(){
	int yy;
	cin>>yy;
	return yy;
}
void PutBack(int x){
	cout<<x<<":"<<endl;
}*/
void Assist(unsigned char A[], int n, int k, int ro) {
	rr=ro;

	for(int i=0;i<ro;i++){
		aa[i]=A[i];
	}
	for(int i=0;i<k;i++){
		cur4.insert(i);
		if(aa[i]=='1'){
			cur3.insert(i);
		}
	//	cur3.insert(i);
	}
	int st=0;
	for (int i = 0; i < n; i++) {
		int req = GetRequest();
		if (cur4.find(req)==cur4.end()){
		 	PutBack((*cur3.begin()));
		 	cur4.erase((*cur3.begin()));
		 	cur3.erase(cur3.begin());
		 	if(aa[i+k]=='1'){
		 		cur3.insert(req);
		 	}
		 	cur4.insert(req);
		}
	}

}

/*int main(){
	int cc[4];
	int nn;
	cin>>nn;
	unsigned char aa[nn];
	for(int i=0;i<nn;i++){
		cin>>aa[i];
	}

	Assist(aa,4,2,nn);
	return 0;
}

*/

Compilation message

/tmp/ccWBwLUx.o: In function `ComputeAdvice(int*, int, int, int)':
advisor.cpp:(.text+0x4d3): undefined reference to `WriteAdvice(int)'
collect2: error: ld returned 1 exit status

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:51:6: warning: unused variable 'st' [-Wunused-variable]
  int st=0;
      ^~