Submission #98209

# Submission time Handle Problem Language Result Execution time Memory
98209 2019-02-21T14:25:48 Z E869120 Last supper (IOI12_supper) C++14
0 / 100
475 ms 29904 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

int post[1 << 18], I[1 << 18]; vector<int> Z[1 << 18];
bool used[1 << 18];

void ComputeAdvice(int *C, int N, int K, int M) {
	for (int i = 0; i < N; i++) Z[C[i]].push_back(i);
	for (int i = 0; i < N; i++) post[i] = (1 << 30);
	for (int i = 0; i < K; i++) {
		for (int j = (int)Z[i].size() - 2; j >= 0; j--) post[Z[i][j]] = Z[i][j + 1];
	}
	
	priority_queue<pair<int, int>, vector<pair<int, int>>, less<pair<int, int>>> que;
	for (int i = 0; i < K; i++) {
		used[i] = true; I[i] = i;
		if (Z[i].size() >= 1) que.push(make_pair(Z[i][0], i));
		else que.push(make_pair((1 << 30), i));
	}
	
	vector<int> L;
	for (int i = 0; i < N; i++) {
		if (used[C[i]] == false) {
			pair<int, int> G = que.top(); que.pop();
			used[G.second] = false; I[C[i]] = I[G.second]; L.push_back(I[C[i]]);
		}
		que.push(make_pair(post[i], C[i])); used[C[i]] = true;
	}
	
	int sz = 1, size_ = 2;
	while (size_ < K) { size_ *= 2; sz++; }
	
	for (int i = 0; i < L.size(); i++) {
		for (int j = 0; j < sz; j++) WriteAdvice((L[i] / (1 << j)) % 2);
	}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

int LL[1 << 18], DAI[1 << 18]; bool used2[1 << 18];

void Assist(unsigned char *A, int N, int K, int R) {
	int sz = 1, size_ = 2;
	while (size_ < K) { size_ *= 2; sz++; }
	
	for (int i = 0; i < R / sz; i++) {
		for (int j = 0; j < sz; j++) { LL[i] += A[i * sz + j] * (1 << j); }
	}
	
	for (int i = 0; i < K; i++) { used2[i] = true; DAI[i] = i; }
	
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int G = GetRequest();
		if (used2[G] == false) {
			int nex = LL[cnt]; //cout << "request = " << G << ", nex = " << nex << ", initial value = " << DAI[nex] << ", num = " << LL[cnt] << endl;
			PutBack(DAI[nex]); cnt++;
			used2[G] = true; used2[DAI[nex]] = false; DAI[nex] = G;
		}
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:34:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < L.size(); i++) {
                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 13056 KB Output is correct
2 Incorrect 11 ms 13056 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 14592 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 315 ms 24968 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 13312 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 338 ms 28016 KB Output isn't correct - not an optimal way
2 Incorrect 475 ms 27928 KB Output isn't correct - not an optimal way
3 Incorrect 369 ms 27704 KB Output isn't correct - not an optimal way
4 Incorrect 367 ms 27760 KB Output isn't correct - not an optimal way
5 Incorrect 354 ms 27512 KB Output isn't correct - not an optimal way
6 Incorrect 371 ms 27704 KB Output isn't correct - not an optimal way
7 Incorrect 357 ms 27400 KB Output isn't correct - not an optimal way
8 Incorrect 413 ms 27584 KB Output isn't correct - not an optimal way
9 Incorrect 376 ms 27512 KB Output isn't correct - not an optimal way
10 Incorrect 362 ms 29904 KB Output isn't correct - not an optimal way