답안 #241469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241469 2020-06-24T08:28:29 Z kshitij_sodani 최후의 만찬 (IOI12_supper) C++17
0 / 100
345 ms 65776 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"
vector<int> ind[1000001];
int cur[1000001];
/*void WriteAdvice(int x){
	cout<<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);
		cur[i]=-1;
	}
	for(int i=0;i<k;i++){
		cur[i]=i;
		kk.insert({ind[i][0],i});

	}
	for(int i=0;i<n;i++){
		if(cur[c[i]]>-1){
			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],c[i]});
			continue;
		}
		auto j=kk.end();
		j--;

		cur[c[i]]=cur[(*j).b];
		cur[(*j).b]=-1;
		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],c[i]});
		for(int j=0;j<15;j++){
			if(((1<<j)&(cur[c[i]]))){
				WriteAdvice(1);
			}
			else{
				WriteAdvice(0);
			}
		}
	//	cout<<cur[c[i]]<<endl;
	}

 //	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> cur;
int ind=0;
unsigned char aa[1000001];
int rr;
int read(){
	int ans=0;
/*	if(ind>=rr){
		while(true){
			continue;
		}
	}*/
	for(int i=0;i<15;i++){
		if(aa[ind+i]=='1'){
			ans+=(1<<i);
		}
	}
	ind+=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 r) {
	rr=r;
	for(int i=0;i<r;i++){
		aa[i]=A[i];
	}

	for(int i=0;i<k;i++){
		arr[i]=i;
		cur.insert(i);

	}
	for (int i = 0; i < n; i++) {
		int req = GetRequest();

		if (cur.find(req)==cur.end()){
			int r=read();
	/*		if(cur.find(arr[r])==cur.end()){
				while(true){
					continue;
				}
			}*/
		 	PutBack(arr[r]);
		 	
		 	cur.erase(arr[r]);
		 	arr[r]=req;
		 	cur.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;
}

*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 47616 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 49408 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 263 ms 60144 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 48128 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 345 ms 63216 KB Output isn't correct - not an optimal way
2 Incorrect 315 ms 63216 KB Output isn't correct - not an optimal way
3 Incorrect 315 ms 63368 KB Output isn't correct - not an optimal way
4 Incorrect 321 ms 63472 KB Output isn't correct - not an optimal way
5 Incorrect 310 ms 63472 KB Output isn't correct - not an optimal way
6 Incorrect 324 ms 63488 KB Output isn't correct - not an optimal way
7 Incorrect 310 ms 63216 KB Output isn't correct - not an optimal way
8 Incorrect 317 ms 63224 KB Output isn't correct - not an optimal way
9 Incorrect 314 ms 63216 KB Output isn't correct - not an optimal way
10 Runtime error 345 ms 65776 KB Execution killed with signal 11 (could be triggered by violating memory limits)