Submission #58832

# Submission time Handle Problem Language Result Execution time Memory
58832 2018-07-19T15:36:14 Z MatheusLealV Last supper (IOI12_supper) C++17
0 / 100
598 ms 113648 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;

void simule(int N, int k, int *C)
{
	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;

		int A = GetRequest();

		PutBack(x);

		pos[x].erase(-tempo);

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

		pos[y].erase(-i);

		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:37:7: warning: unused variable 'A' [-Wunused-variable]
   int A = GetRequest();
       ^
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:69:13: warning: unused variable 'k' [-Wunused-variable]
  int n = N, k = K, r = R, sz = (log2(n));
             ^
assistant.cpp:69:20: warning: unused variable 'r' [-Wunused-variable]
  int n = N, k = K, r = R, sz = (log2(n));
                    ^
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 47720 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 95632 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 384 ms 102872 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 109168 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 581 ms 110732 KB Error - Putting back a color when it is already on the scaffold
2 Incorrect 450 ms 112388 KB Error - Putting back a color when it is already on the scaffold
3 Incorrect 588 ms 112720 KB Error - Putting back a color when it is already on the scaffold
4 Incorrect 453 ms 112980 KB Error - Putting back a color when it is already on the scaffold
5 Incorrect 493 ms 113024 KB Error - Putting back a color when it is already on the scaffold
6 Incorrect 456 ms 113348 KB Error - Putting back a color when it is already on the scaffold
7 Incorrect 577 ms 113648 KB Error - Putting back a color when it is already on the scaffold
8 Incorrect 511 ms 113648 KB Error - Putting back a color when it is already on the scaffold
9 Incorrect 598 ms 113648 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 547 ms 113648 KB Error - Putting back a color when it is already on the scaffold