This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "advisor.h"
void ComputeAdvice(int *C, int N, int K, int M) {
int x = 1;
while (N > (1 << x)) x++;
for (int i = 0; i < N; i++) {
for (int j = 0; j < x; j++) {
//printf("%c", '0' + !!(C[i] & (1 << j)));
WriteAdvice(!!(C[i] & (1 << j)));
}
}
//printf("\n");
}
#include <bits/stdc++.h>
#include "assistant.h"
#define X first
#define Y second
using namespace std;
const int maxn = 1e5+10;
queue< int > qs[maxn];
void Assist(unsigned char *A, int N, int K, int R) {
int x = 1;
while (N > (1 << x)) x++;
int ptr = 0;
vector< int > c;
for (int i = 0; i < N; i++) {
int ac = 0;
for (int j = 0; j < x; j++) {
//printf("pokusaj: %c\n", A[ptr]);
if (A[ptr++] == 1) ac += (1 << j);
}
c.push_back(ac);
}
//printf("\n");
for (int i = 0; i < N; i++) qs[i].push(N + 1);
for (int i = 0; i < N; i++) {
qs[c[i]].push(i);
}
set< pair<int, int> > s;
for (int i = 0; i < K; i++) {
s.insert({qs[i].front(), i});
}
for (int i = 0; i < N; i++) {
int deb = GetRequest();
//printf("debug: %d %d\n", deb, c[i]); fflush(stdout);
assert(c[i] == deb);
int tr = c[i];
if (!s.count({qs[tr].front(), tr})) {
int x = s.rbegin()->Y;
PutBack(x);
s.erase(--s.end());
qs[tr].pop();
s.insert({qs[tr].front(), tr});
} else {
s.erase({qs[tr].front(), tr});
qs[tr].pop();
s.insert({qs[tr].front(), tr});
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |