Submission #118486

# Submission time Handle Problem Language Result Execution time Memory
118486 2019-06-19T05:23:37 Z E869120 Last supper (IOI12_supper) C++14
0 / 100
150 ms 20376 KB
#include "advisor.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;

int E[100009], F[100009], A1[100009], A2[100009]; vector<int>X[100009];
priority_queue<pair<int, int>, vector<pair<int, int>>, less<pair<int, int>>>Q;

void ComputeAdvice(int *C, int N, int K, int M) {
	int BITS = 0; for (int i = 0; i < 19; i++) { if ((1 << i) >= K) { BITS = i; break; } }

	for (int i = 0; i < N; i++) X[C[i]].push_back(i);
	for (int i = 0; i < N; i++) X[i].push_back(N);
	for (int i = 0; i < N; i++) E[i] = -1;
	for (int i = 0; i < K; i++) E[i] = i;
	for (int i = 0; i < N; i++) { Q.push(make_pair(X[i][0], i)); }

	for (int i = 0; i < N; i++) {
		while (true) {
			int pos1 = Q.top().first, pos2 = Q.top().second;
			if (E[pos2] == -1) Q.pop();
			else break;
		}
		if (E[C[i]] != -1) {
			A1[i] = 1; // 前に線がある
			F[i] = -1;
			int pos1 = lower_bound(X[C[i]].begin(), X[C[i]].end(), i) - X[C[i]].begin(); pos1--;
			if (pos1 >= 0) A2[X[C[i]][pos1]] = 1;
		}
		else {
			A1[i] = 0; // 前に線が無い
			int pos1 = Q.top().second;
			F[i] = E[pos1];
			E[pos1] = -1;
			E[C[i]] = F[i];
		}
		int pos1 = lower_bound(X[C[i]].begin(), X[C[i]].end(), i + 1) - X[C[i]].begin();
		Q.push(make_pair(X[C[i]][pos1], C[i]));
	}

	for (int i = 0; i < N; i++) WriteAdvice(A1[i]);
	for (int i = 0; i < N; i++) WriteAdvice(A2[i]);
}
#include "assistant.h"
#include <iostream>
#include <queue>
using namespace std;

int LIST[100009], B1[100009], B2[100009];
vector<int>vec; bool used[100009];

void Assist(unsigned char *A, int N, int K, int R) {
	for (int i = 0; i < N; i++) B1[i] = A[i];
	for (int i = 0; i < N; i++) B2[i] = A[i + N];
	for (int i = 0; i < K; i++) used[i] = true;

	for (int i = 0; i < N; i++) {
		LIST[i] = GetRequest();
		if (B1[i] == 1) {
			// 無視する
		}
		else {
			int pos = -1;
			for (int j = 0; j < vec.size(); j++) {
				if (used[LIST[vec[j]]] == true) pos = vec[j];
			}
			PutBack(LIST[pos]); used[LIST[pos]] = false;
			used[LIST[i]] = true;
			vector<int>vec2;
			for (int j = 0; j < vec.size(); j++) {
				if (j != pos) vec2.push_back(vec[j]);
			}
			vec = vec2;
		}
		if (B2[i] == 0) vec.push_back(i);
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:23:8: warning: unused variable 'pos1' [-Wunused-variable]
    int pos1 = Q.top().first, pos2 = Q.top().second;
        ^~~~
advisor.cpp:13:6: warning: variable 'BITS' set but not used [-Wunused-but-set-variable]
  int BITS = 0; for (int i = 0; i < 19; i++) { if ((1 << i) >= K) { BITS = i; break; } }
      ^~~~

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:21:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int j = 0; j < vec.size(); j++) {
                    ~~^~~~~~~~~~~~
assistant.cpp:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int j = 0; j < vec.size(); j++) {
                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5376 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 6912 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 17224 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 6232 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 150 ms 20120 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 127 ms 19936 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 141 ms 20120 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 135 ms 20320 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 134 ms 20192 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 140 ms 20192 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 139 ms 20192 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 142 ms 20376 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 134 ms 20136 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 130 ms 19168 KB Error - Putting back a color that is not on the scaffold