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"
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define uni(a) a.resize(unique(iter(a)));
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
using pii = pair<int, int>;
int sz;
void trans(int num){
for(int i = 0; i < sz; i++){
if(1 << i & num) WriteAdvice(1);
else WriteAdvice(0);
}
}
void ComputeAdvice(int *C, int n, int k, int M){
sz = __lg(k) + 1;
vector<int> table(k);
for(int i = 0; i < k; i++) table[i] = i;
vector<queue<int>> pos(n);
for(int i = 0; i < n; i++){
pos[C[i]].push(i);
}
for(int i = 0; i < n; i++) pos[i].push(n);
set<pii> st;
map<int, int> tp;
for(int i = 0; i < n; i++) tp[i] = -1;
for(int i = 0; i < k; i++){
st.insert(mp(pos[i].front(), i));
tp[i] = i;
}
for(int i = 0; i < n; i++){
int c = C[i];
pos[c].pop();
if(tp[c] != -1){
st.erase(mp(i, c));
st.insert(mp(pos[c].front(), c));
continue;
}
int rm = st.rbegin()->S;
st.erase(prev(st.end()));
trans(tp[rm]);
tp[c] = tp[rm];
tp[rm] = -1;
st.insert(mp(pos[c].front(), c));
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define uni(a) a.resize(unique(iter(a)));
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
using pii = pair<int, int>;
namespace{
int sz;
}
int ap = 0;
int trans(unsigned char *A){
int ans = 0;
for(int i = 0; i < sz; i++){
if(A[ap + i]) ans |= 1 << i;
}
ap += sz;
return ans;
}
void Assist(unsigned char *A, int n, int k, int m){
sz = __lg(k) + 1;
vector<int> table(k);
vector<bool> ok(n);
for(int i = 0; i < k; i++) table[i] = i, ok[i] = true;
for(int i = 0; i < n; i++){
int c = GetRequest();
if(ok[c]) continue;
int r = trans(A);
PutBack(table[r]);
ok[table[r]] = false;
ok[c] = true;
table[r] = c;
}
}
# | 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... |