Submission #393900

# Submission time Handle Problem Language Result Execution time Memory
393900 2021-04-24T19:57:41 Z rainboy Last supper (IOI12_supper) C
0 / 100
509 ms 14596 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);
}

int 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;
}

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

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

void Assist(unsigned char *cc, int n, int k, int r) {
  int i, l;

	l = 0;
	while (1 << l < n + 1)
		l++;
  for (i = 0; i < n; i++) {
		int h, a;

    GetRequest();
		a = 0;
		for (h = 0; h < l; h++)
			if (cc[i * l + h])
				a |= 1 << h;
		if (a != n)
			PutBack(a);
  }
}

Compilation message

advisor.c: In function 'pq_up':
advisor.c:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^
advisor.c: In function 'pq_dn':
advisor.c:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Incorrect 2 ms 492 KB Error - Not putting back color when it is not on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1724 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 350 ms 11776 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 2 ms 620 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 444 ms 14452 KB Error - Not putting back color when it is not on the scaffold
2 Incorrect 434 ms 14388 KB Error - Not putting back color when it is not on the scaffold
3 Incorrect 509 ms 14384 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 472 ms 14476 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 434 ms 14392 KB Error - Not putting back color when it is not on the scaffold
6 Incorrect 440 ms 14500 KB Error - Not putting back color when it is not on the scaffold
7 Incorrect 429 ms 14456 KB Error - Not putting back color when it is not on the scaffold
8 Incorrect 451 ms 14472 KB Error - Not putting back color when it is not on the scaffold
9 Incorrect 459 ms 14452 KB Error - Not putting back color when it is not on the scaffold
10 Incorrect 449 ms 14596 KB Error - Not putting back color when it is not on the scaffold