답안 #241744

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241744 2020-06-25T12:12:50 Z kshitij_sodani 최후의 만찬 (IOI12_supper) C++17
0 / 100
254 ms 63216 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;
int prev2[2000001];
/*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});
		prev2[i]=i;
		cur.insert(i);
	}

	for(int i=0;i<n;i++){
		if(cur.find(c[i])!=cur.end()){

			kk.erase({i,prev2[c[i]]});
			prev2[c[i]]=i+k;
			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});
		prev2[c[i]]=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;
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 aa[], int n, int k, int ro) {
/*	rr=ro;

	for(int i=0;i<ro;i++){
		aa[i]=A[i];
	}*/
  return;
	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);
		}
		else{
			if(cur3.find(req)!=cur3.end()){
				cur3.erase(req);
			}
			if(aa[i+k]=='1'){
				cur3.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;
      ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 47616 KB Error - GetRequest() must be called N times
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 49152 KB Error - GetRequest() must be called N times
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 170 ms 59888 KB Error - GetRequest() must be called N times
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 48384 KB Error - GetRequest() must be called N times
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 231 ms 62192 KB Error - GetRequest() must be called N times
2 Incorrect 236 ms 62448 KB Error - GetRequest() must be called N times
3 Incorrect 235 ms 63216 KB Error - GetRequest() must be called N times
4 Incorrect 217 ms 63216 KB Error - GetRequest() must be called N times
5 Incorrect 213 ms 63216 KB Error - GetRequest() must be called N times
6 Incorrect 207 ms 63216 KB Error - GetRequest() must be called N times
7 Incorrect 205 ms 63216 KB Error - GetRequest() must be called N times
8 Incorrect 206 ms 63216 KB Error - GetRequest() must be called N times
9 Incorrect 201 ms 63216 KB Error - GetRequest() must be called N times
10 Incorrect 254 ms 62960 KB Error - GetRequest() must be called N times