This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In the name of God
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll a[maxn], ok[maxn], ptr[maxn], prio[maxn], ind[maxn];
vector<ll> vec[maxn];
set<pll> st;
void ComputeAdvice(int *c, int n, int k, int m){
ll lg = 0;
while((1 << lg) < k) lg++;
for(ll i = 0; i < k; i++){
a[i] = i;
ind[i] = i;
ok[i] = 1;
}
for(ll i = 0; i < n; i++){
vec[c[i]].pb(i);
}
for(ll i = 0; i < n; i++){
vec[i].pb(n);
vec[i].pb(n);
}
for(ll i = 0; i < n; i++){
prio[i] = vec[i][ptr[i]++];
if(i < k) st.insert(Mp(-prio[i], i));
}
for(ll i = 0; i < n; i++){
if(ok[c[i]]){
st.erase(Mp(-prio[c[i]], c[i]));
prio[c[i]] = vec[c[i]][ptr[c[i]]++];
st.insert(Mp(-prio[c[i]], c[i]));
continue;
}
ll j = st.begin()->S;
st.erase(st.begin());
ok[j] = 0;
ok[c[i]] = 1;
ind[c[i]] = ind[j];
prio[c[i]] = vec[c[i]][ptr[c[i]]++];
st.insert(Mp(-prio[c[i]], c[i]));
for(ll o = 0; o < lg; o++){
WriteAdvice((ind[j] >> o) & 1);
//cout << ((ind[j] >> o) & 1);
}
}
}
/*int main(){
int c[100], n, k, m;
cin >> n >> k >> m;
for(ll i = 0; i < n; i++){
cin >> c[i];
}
ComputeAdvice(c, n, k, m);
}*/
//In the name of God
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll a[maxn], ok[maxn];
void Assist(unsigned char *A, int n, int k, int r) {
ll lg = 0;
while((1 << lg) < k) lg++;
ll ptr = 0;
for(ll i = 0; i < k; i++){
a[i] = i;
ok[i] = 1;
}
for(ll i = 0; i < n; i++){
ll x = GetRequest();
if(ok[x]) continue;
ll y = 0;
for(ll j = 0; j < lg; j++){
if(A[ptr++] == 1) y += (1 << j);
}
PutBack(a[y]);
ok[a[y]] = 0;
a[y] = x;
ok[a[y]] = 1;
}
}
# | 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... |