제출 #116759

#제출 시각아이디문제언어결과실행 시간메모리
116759faustaadp최후의 만찬 (IOI12_supper)C++17
34 / 100
337 ms31420 KiB

#include "advisor.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll a[101010];
ll w[101010];
ll ada[101010];
ll las[101010];
ll lok[101010];
ll loki[101010];
ll y[101010];
void ComputeAdvice(int *C, int N, int K, int M) 
{
	priority_queue<pair<ll,ll> > pq;
	ll i,j;
	ll x=ceil(log(K+1)/log(2));
	for(i=0;i<N;i++)
		a[i]=C[i];
	for(i=0;i<N;i++)
  	{
  	//	cout<<i<<" "<<isi[i]<<"\n";
  		las[i]=N;
  	}
  	for(i=N-1;i>=0;i--)
  	{
  		y[i]=las[a[i]];
  		las[a[i]]=i;
  	}
  	for(i=0;i<K;i++)
  	{
  		pq.push(mp(las[i],i));
  		ada[i]=1;
  		lok[i]=i;
  		loki[i]=i;
  	}
	for (i = 0; i < N; i++) 
  	{
	    int req = a[i];
  		if(ada[req])
  		{
  			w[i]=K;
  			las[a[i]]=y[i];
	  		pq.push(mp(las[a[i]],a[i]));
  		}
  		else
  		{
	  		while(!pq.empty()&&ada[pq.top().se]==0)pq.pop();
	  		while(!pq.empty()&&las[pq.top().se]!=pq.top().fi)pq.pop();
	  		ada[req]=1;
	  		ll tem=pq.top().se;
	  		ll za=loki[tem];
	  		lok[za]=req;
	  		loki[req]=za;
	  		w[i]=za;
	//  		cout<<i<<" "<<tem<<" "<<za<<"_)	\n";
	  //		cout<<lok[0]<<"   "<<lok[1]<<"\n";
	  		pq.pop();
	  		ada[tem]=0;
	  		las[a[i]]=y[i];
	  		pq.push(mp(las[a[i]],a[i]));
  		}
  	}
	for(i=0;i<N;i++)
	{
		for(j=0;j<x;j++)
			if(w[i]&(1<<j))
			{
			//	cout<<"_1\n";
				WriteAdvice(1);
			}
			else
			{
			//	cout<<"_0\n";
				WriteAdvice(0);
			}
	}
}
#include "assistant.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll z[2010101],isi[101010];
ll loka[101010];
void Assist(unsigned char *A, int N, int K, int R) 
{
	ll i,j;
	ll x=ceil(log(K+1)/log(2));
  	for (i = 0; i < R; i++)
  	{
  		if(A[i])
  		{
  			z[i]=1;
  		}
  		//cout<<i<<"___"<<A[i]<<"\n";
  		//z[(ll)A[i]]=1; 
  	}
  	for (i = 0; i < N; i++) 
  		for(j=0;j<x;j++)
  			isi[i]+=z[i*x+j]*(1<<j);
  	//for (i = 0; i < N; i++)
  //		cout<<i<<" "<<isi[i]<<"\n"; 
  	for (i = 0; i < K; i++)
  		loka[i]=i; 
  	for (i = 0; i < N; i++) 
  	{
	    int req = GetRequest();
  		if(isi[i]==K)
  		{
  		}
  		else
  		{
	  		ll za=isi[i];
	  		PutBack(loka[za]);
	  		loka[za]=req;
  		}
  	}
 
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...