Submission #241738

# Submission time Handle Problem Language Result Execution time Memory
241738 2020-06-25T12:03:12 Z kshitij_sodani Last supper (IOI12_supper) C++17
0 / 100
2500 ms 67056 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 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

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:51:6: warning: unused variable 'st' [-Wunused-variable]
  int st=0;
      ^~
# Verdict Execution time Memory Grader output
1 Execution timed out 2577 ms 47872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2579 ms 49408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2599 ms 62944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2570 ms 48384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2584 ms 66032 KB Time limit exceeded
2 Execution timed out 2544 ms 66544 KB Time limit exceeded
3 Execution timed out 2536 ms 66800 KB Time limit exceeded
4 Execution timed out 2529 ms 66800 KB Time limit exceeded
5 Execution timed out 2537 ms 67056 KB Time limit exceeded
6 Execution timed out 2533 ms 66800 KB Time limit exceeded
7 Execution timed out 2544 ms 67056 KB Time limit exceeded
8 Execution timed out 2535 ms 66800 KB Time limit exceeded
9 Execution timed out 2561 ms 67008 KB Time limit exceeded
10 Execution timed out 2506 ms 63472 KB Time limit exceeded