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 <bits/stdc++.h>
#include "advisor.h"
using namespace std;
string dectobin(int x, int mx) {
string res = "";
for (int i = mx; i >= 0; i--) {
if ((1 << i) & x) res += '1';
else res += '0';
}
return res;
}
void ComputeAdvice(int *C, int N, int K, int M) {
int mx = log2(N-1);
for (int i = 0; i < N; i++) {
string tmp = dectobin(C[i],mx);
for (auto j : tmp) WriteAdvice(j-'0');
}
}
#include <bits/stdc++.h>
#define f first
#define s second
#include "assistant.h"
using namespace std;
int C[100005];
deque<int> pos[100005];
void Assist(unsigned char *A, int N, int K, int R) {
int lg = log2(N-1)+1;
for (int i = 0; i < R; i++) {
C[i/lg] += (1 << (lg - i % lg - 1)) * A[i];
}
for (int i = 0; i < N; i++) pos[C[i]].push_back(i);
for (int i = 0; i < N; i++) pos[i].push_back(1e9);
set<pair<int,int>> cur;
for (int i = 0; i < K; i++) cur.insert({pos[i][0],i});
for (int i = 0; i < N; i++) {
GetRequest();
if (cur.find({pos[C[i]][0],C[i]}) != cur.end()) {
cur.erase({pos[C[i]][0],C[i]});
pos[C[i]].pop_front();
cur.insert({pos[C[i]][0],C[i]});
} else {
pos[C[i]].pop_front();
PutBack((*cur.rbegin()).s);
cur.erase(*cur.rbegin());
cur.insert({pos[C[i]][0],C[i]});
}
}
}
# | 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... |