Submission #393906

# Submission time Handle Problem Language Result Execution time Memory
393906 2021-04-24T20:18:40 Z rainboy Last supper (IOI12_supper) C
25 / 100
455 ms 16628 KB
#include "advisor.h"
#include <string.h>

#define N	100000

int ii[N], iq[1 + N], pq[N], cnt;

int lt(int i, int j) { return ii[i] > ii[j]; }

int p2(int p) {
	return (p *= 2) > cnt ? 0 : (p < cnt && lt(iq[p + 1], iq[p]) ? p + 1 : p);
}

void pq_up(int i) {
	int p, q, j;

	for (p = pq[i]; (q = p / 2) && lt(i, j = iq[q]); p = q)
		iq[pq[j] = p] = j;
	iq[pq[i] = p] = i;
}

void pq_dn(int i) {
	int p, q, j;

	for (p = pq[i]; (q = p2(p)) && lt(j = iq[q], i); p = q)
		iq[pq[j] = p] = j;
	iq[pq[i] = p] = i;
}

void pq_add(int i) {
	pq[i] = ++cnt, pq_up(i);
}

int pq_remove_first() {
	int i = iq[1], j = iq[cnt--];

	if (j != i)
		pq[j] = 1, pq_dn(j);
	pq[i] = 0;
	return i;
}

void print(int a, int l) {
	int h;

	for (h = 0; h < l; h++)
		WriteAdvice(a >> h & 1);
}

void ComputeAdvice(int *aa, int n, int k, int m) {
	static int qq[N], next[N], hh[N];
	static char used[N];
	int l, h, i, a;

	for (a = 0; a < n; a++)
		next[a] = n;
	for (i = n - 1; i >= 0; i--) {
		qq[i] = next[aa[i]];
		next[aa[i]] = i;
	}
	for (a = 0; a < k; a++)
		iq[pq[a] = ++cnt] = a, ii[a] = next[a], hh[a] = a;
	for (h = cnt / 2; h > 0; h--)
		pq_dn(iq[h]);
	memset(used, 1, k * sizeof *used);
	l = 0;
	while (1 << l < k + 1)
		l++;
	for (i = 0; i < n; i++)
		if (used[aa[i]])
			print(k, l), ii[aa[i]] = qq[i], pq_up(aa[i]);
		else {
			int a;

			a = pq_remove_first(), print(hh[a], l), used[a] = 0;
			hh[aa[i]] = hh[a], ii[aa[i]] = qq[i], pq_add(aa[i]), used[aa[i]] = 1;
		}
}
#include "assistant.h"

#define K	25000

void Assist(unsigned char *cc, int n, int k, int r) {
	static int aa[K];
	int l, h, h_, i;

	l = 0;
	while (1 << l < k + 1)
		l++;
	for (h = 0; h < k; h++)
		aa[h] = h;
	for (i = 0; i < n; i++) {
		int a = GetRequest();

		h_ = 0;
		for (h = 0; h < l; h++)
			if (cc[i * l + h])
				h_ |= 1 << h;
		if (h_ != k)
			PutBack(aa[h_]), aa[h_] = a;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Correct 4 ms 648 KB Output is correct
4 Correct 5 ms 668 KB Output is correct
5 Correct 4 ms 780 KB Output is correct
6 Correct 11 ms 964 KB Output is correct
7 Correct 13 ms 1116 KB Output is correct
8 Correct 14 ms 1120 KB Output is correct
9 Correct 15 ms 1148 KB Output is correct
10 Correct 17 ms 1172 KB Output is correct
11 Correct 18 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1588 KB Output is correct
2 Correct 164 ms 6252 KB Output is correct
3 Runtime error 455 ms 16628 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 315 ms 11080 KB Output is correct
2 Correct 412 ms 13652 KB Output is correct
3 Correct 388 ms 14864 KB Output is correct
4 Correct 389 ms 14900 KB Output is correct
5 Correct 402 ms 14856 KB Output is correct
6 Correct 385 ms 14836 KB Output is correct
7 Correct 385 ms 14924 KB Output is correct
8 Correct 396 ms 14996 KB Output is correct
9 Correct 388 ms 14960 KB Output is correct
10 Correct 409 ms 15096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 620 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 396 ms 13616 KB Output is partially correct - 1500000 bits used
2 Correct 387 ms 13800 KB Output is partially correct - 1500000 bits used
3 Correct 393 ms 13728 KB Output is partially correct - 1500000 bits used
4 Correct 398 ms 13816 KB Output is partially correct - 1500000 bits used
5 Correct 388 ms 13800 KB Output is partially correct - 1500000 bits used
6 Correct 392 ms 13780 KB Output is partially correct - 1500000 bits used
7 Correct 399 ms 13792 KB Output is partially correct - 1497585 bits used
8 Correct 409 ms 13684 KB Output is partially correct - 1500000 bits used
9 Correct 387 ms 13792 KB Output is partially correct - 1500000 bits used
10 Correct 384 ms 13800 KB Output is partially correct - 1500000 bits used