Submission #393901

#TimeUsernameProblemLanguageResultExecution timeMemory
393901rainboyLast supper (IOI12_supper)C11
0 / 100
466 ms14640 KiB
#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]]) print(n, l), ii[aa[i]] = qq[i], pq_dn(aa[i]); else { int a; a = pq_remove_first(), print(a, l), used[a] = 0; ii[aa[i]] = qq[i], pq_add(aa[i]), used[aa[i]] = 1; } }
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...