답안 #393907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393907 2021-04-24T20:20:49 Z rainboy 최후의 만찬 (IOI12_supper) C
34 / 100
411 ms 14368 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 N	100000

void Assist(unsigned char *cc, int n, int k, int r) {
	static int aa[N];
	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;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 4 ms 640 KB Output is correct
4 Correct 5 ms 656 KB Output is correct
5 Correct 3 ms 780 KB Output is correct
6 Correct 11 ms 960 KB Output is correct
7 Correct 14 ms 1112 KB Output is correct
8 Correct 17 ms 1128 KB Output is correct
9 Correct 15 ms 1088 KB Output is correct
10 Correct 19 ms 1136 KB Output is correct
11 Correct 15 ms 1136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 1520 KB Output is correct
2 Correct 161 ms 6076 KB Output is correct
3 Correct 401 ms 14368 KB Output is correct
4 Correct 180 ms 8168 KB Output is correct
5 Correct 283 ms 10688 KB Output is correct
6 Correct 348 ms 12308 KB Output is correct
7 Correct 396 ms 13936 KB Output is correct
8 Correct 332 ms 11768 KB Output is correct
9 Correct 131 ms 6928 KB Output is correct
10 Correct 388 ms 13764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 318 ms 11140 KB Output is correct
2 Correct 390 ms 13800 KB Output is correct
3 Correct 392 ms 13856 KB Output is correct
4 Correct 390 ms 13996 KB Output is correct
5 Correct 377 ms 13572 KB Output is correct
6 Correct 398 ms 13920 KB Output is correct
7 Correct 382 ms 13736 KB Output is correct
8 Correct 386 ms 13892 KB Output is correct
9 Correct 391 ms 13852 KB Output is correct
10 Correct 391 ms 13668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 616 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 394 ms 13700 KB Output is partially correct - 1500000 bits used
2 Correct 393 ms 13716 KB Output is partially correct - 1500000 bits used
3 Correct 385 ms 13672 KB Output is partially correct - 1500000 bits used
4 Correct 389 ms 13788 KB Output is partially correct - 1500000 bits used
5 Correct 407 ms 13712 KB Output is partially correct - 1500000 bits used
6 Correct 388 ms 13740 KB Output is partially correct - 1500000 bits used
7 Correct 386 ms 14008 KB Output is partially correct - 1497585 bits used
8 Correct 411 ms 13728 KB Output is partially correct - 1500000 bits used
9 Correct 390 ms 13924 KB Output is partially correct - 1500000 bits used
10 Correct 408 ms 13764 KB Output is partially correct - 1500000 bits used