Submission #280492

# Submission time Handle Problem Language Result Execution time Memory
280492 2020-08-22T20:31:02 Z amiratou Last supper (IOI12_supper) C++14
0 / 100
327 ms 25040 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz(x) (int)(x.size())
typedef pair<int,int> ii;
const int INF = (int)(1e9);

vector<int> vec[100005];
int occ[100005];
set<ii,greater<ii> > myset;
int pos[100005],in[100005];

void ComputeAdvice(int *C, int N, int K, int M) {
	int l=31-__builtin_clz(K+1)+1;
	for (int i = 0; i < N; ++i)
	{
		occ[i]=sz(vec[C[i]]);
		vec[C[i]].push_back(i);
	}
	for (int i = 0; i < K; ++i){
		pos[i]=i,in[i]=1;
		if(!sz(vec[i]))myset.insert({INF,i});
		else myset.insert({vec[i][0],i});
	}
	vector<int> code;
	for (int i = 0; i < N; ++i)
	{
		if(in[C[i]]){
			myset.erase({i,C[i]});
			if((occ[i]+1)<sz(vec[C[i]]))myset.insert({vec[C[i]][occ[i]+1],C[i]});
			else myset.insert({INF,C[i]});
		}
		else{
			ii h=*myset.begin();
			myset.erase(myset.begin());
			code.push_back(h.se);
			in[h.se]=0,in[C[i]]=1;
			if((occ[i]+1)<sz(vec[C[i]]))myset.insert({vec[C[i]][occ[i]+1],C[i]});
			else myset.insert({INF,C[i]});
			pos[C[i]]=pos[h.se];
		}
		/*for(auto it:myset){
			cerr<<it.fi<<","<<it.se<<"\n";
		}
		cerr<<"--------\n";*/
	}
	//cerr<<l<<" ";
	for(auto it:code){
		//cerr<<it<<" ";
		for (int i = 0; i < l; ++i){
			//cerr<<((it>>i)&1)<<" ";
			WriteAdvice(((it>>i)&1));
		}
		//cerr<<"\n";
	}
	//cerr<<"\n";
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz(x) (int)(x.size())
typedef pair<int,int> ii;
const int INF = (int)(1e9);

int tab[100005],here[100005];

void Assist(unsigned char *A, int N, int K, int R) {
	int l=31-__builtin_clz(K+1)+1;
	for (int i = 0; i < K; ++i)
		tab[i]=i,here[i]=1;
	assert(!(R%l));
	vector<int> vec;
	for (int i = 0; i < R; i+=l)
	{
		int nb=0;
		for (int j = 0; j < l; ++j)
			if(A[i+j]==1)nb+=(1<<j);
		vec.push_back(nb);
	}
	int idx=0;
	for (int i = 0; i < N; ++i)
	{
		int h=GetRequest();
		if(!here[h]){
			assert(idx<sz(vec));
			here[vec[idx]]=0;
			here[h]=1;
			PutBack(vec[idx]),idx++;
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5376 KB Output is correct
2 Incorrect 2 ms 5376 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 6912 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 212 ms 17592 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5888 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 283 ms 20304 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 267 ms 20584 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 260 ms 20600 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 254 ms 20600 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 261 ms 20600 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 264 ms 20712 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 254 ms 20592 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 257 ms 20864 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 259 ms 20600 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 327 ms 25040 KB Error - Putting back a color that is not on the scaffold