답안 #58837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58837 2018-07-19T15:46:08 Z MatheusLealV 최후의 만찬 (IOI12_supper) C++17
0 / 100
653 ms 122888 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 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));
                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 47828 KB Output is correct
2 Incorrect 53 ms 94928 KB Error - Putting back a color when it is already on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 97 ms 96144 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 540 ms 106980 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 116624 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 625 ms 119156 KB Error - Putting back a color when it is already on the scaffold
2 Incorrect 597 ms 121760 KB Error - Putting back a color when it is already on the scaffold
3 Incorrect 566 ms 122140 KB Error - Putting back a color when it is already on the scaffold
4 Incorrect 580 ms 122500 KB Error - Putting back a color when it is already on the scaffold
5 Incorrect 569 ms 122556 KB Error - Putting back a color when it is already on the scaffold
6 Incorrect 653 ms 122560 KB Error - Putting back a color when it is already on the scaffold
7 Incorrect 521 ms 122624 KB Error - Putting back a color when it is already on the scaffold
8 Incorrect 536 ms 122756 KB Error - Putting back a color when it is already on the scaffold
9 Incorrect 582 ms 122824 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 630 ms 122888 KB Error - Not putting back color when it is not on the scaffold