Submission #58838

# Submission time Handle Problem Language Result Execution time Memory
58838 2018-07-19T15:47:50 Z MatheusLealV Last supper (IOI12_supper) C++17
0 / 100
754 ms 123832 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;

		dentro.erase(x);
		dentro.insert(A);


		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 Assist(unsigned char*, int, int, int)':
assistant.cpp:88:13: warning: unused variable 'k' [-Wunused-variable]
  int n = N, k = K, r = R, sz = (log2(n));
             ^
assistant.cpp:88:20: warning: unused variable 'r' [-Wunused-variable]
  int n = N, k = K, r = R, sz = (log2(n));
                    ^
# Verdict Execution time Memory Grader output
1 Correct 52 ms 47716 KB Output is correct
2 Incorrect 46 ms 94680 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 96164 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 595 ms 107600 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 117552 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 667 ms 120032 KB Output isn't correct - not an optimal way
2 Incorrect 711 ms 122796 KB Output isn't correct - not an optimal way
3 Incorrect 693 ms 123444 KB Output isn't correct - not an optimal way
4 Incorrect 754 ms 123808 KB Output isn't correct - not an optimal way
5 Incorrect 751 ms 123808 KB Output isn't correct - not an optimal way
6 Incorrect 702 ms 123820 KB Output isn't correct - not an optimal way
7 Incorrect 665 ms 123832 KB Output isn't correct - not an optimal way
8 Incorrect 641 ms 123832 KB Output isn't correct - not an optimal way
9 Incorrect 657 ms 123832 KB Output isn't correct - not an optimal way
10 Incorrect 717 ms 123832 KB Output isn't correct - not an optimal way