Submission #58835

# Submission time Handle Problem Language Result Execution time Memory
58835 2018-07-19T15:45:22 Z MatheusLealV Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "advisor.h"
#define inf 1000000000
#define maxn 100050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;

int n, k, m, sz, t = 0, id = 0;

void write(int x)
{	for(int i = 0; i <= sz; i++)
	{
		t++;

		//cout<<"QTD "<<t<<"\n";
		if(x & (1<<i))
		{
			WriteAdvice(1);

			//cout<<"ADD 1\n";
		}

		else
		{
			WriteAdvice(0);

			//cout<<"ADD 0\n";
		}

		id ++;
	}
}

void ComputeAdvice(int *C, int N, int K, int M)
{
	n = N, k = K, m = M;

	sz = log2(n);

	for(int i = 0; i < N; i++) write(C[i]);


}
#include <bits/stdc++.h>
#include "assistant.h"
#define inf 1000000000
#define maxnn 1000050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;

vector<int> order;

set<int> pos[maxnn];

set< pii > inside;

vector<int> opt;

void simule(int N, int k, int *C)
{

	for(int i = 0; i < n; i++)
	{
		pos[C[i]].insert(i);
	}

	for(int i = 0; i < k; i++)
	{
		int prox = inf;

		if(!pos[i].empty()) prox = *(pos[i].begin());

		inside.insert({-prox, i});
	}
	//vector<int> opt_order;

	set<int> dentro;

	for(int i = 0; i < k; i++) dentro.insert(i);

	for(int i = 0; i < N; i++)
	{
		int tempo = (*(inside.begin())).f, x = (*(inside.begin())).s;

		//cout<<"REMOVE "<<x<<"\n";

		int A = GetRequest();

		if(dentro.count(A)) continue;

		PutBack(x);

		opt.push_back(x);

		pos[x].erase(-tempo);

		int prox = inf, y = C[i];

		pos[y].erase(-i);
//
	//	cout<<"COLOCA "<<y<<"\n";

		if(!pos[y].empty()) prox = *(pos[y].begin());

		if(inside.count({-prox, y})) continue;

		inside.erase({tempo, x});
		
		inside.insert({-prox, y});
		//cout<<"REMOVENDO "<<x<<" "<<tempo<<"\n";

		//cout<<"QTD "<<t<<"\n";

		//write(x);

		//cout<<"REMOVE "<<x<<" "<<"ADD "<<y<<"\n";


		//cout<<"COLOCANDO "<<y<<" "<<prox<<"\n";
	}
}

void Assist(unsigned char *A, int N, int K, int R)
{
	int n = N, k = K, r = R, sz = (log2(n));

	int C[maxnn];

	for(int i = 0, l = 0; i < R; i += sz + 1)
	{
		int num = 0, id = 0;

		for(int j = i ; j <= i + sz; j++, id ++)
		{
			if(A[j] == 1) num += (1<<id);
		}

		C[l] = num;

		l++;
	}

	simule(N, K, C);
}

Compilation message

assistant.cpp: In function 'void simule(int, int, int*)':
assistant.cpp:21:21: error: 'n' was not declared in this scope
  for(int i = 0; i < n; i++)
                     ^
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:84:13: warning: unused variable 'k' [-Wunused-variable]
  int n = N, k = K, r = R, sz = (log2(n));
             ^
assistant.cpp:84:20: warning: unused variable 'r' [-Wunused-variable]
  int n = N, k = K, r = R, sz = (log2(n));
                    ^