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>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
static queue<int> q[100010];
static set<pii> s;
static bool ans[200010];
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0; i<N; i++) {
q[C[i]].em(i);
}
for(int i=0; i<N; i++)
q[i].em(N);
for(int i=0; i<K; i++) {
s.insert(mp(q[i].front(), i));
}
for(int i=0; i<N; i++) {
if(s.begin()->fi == i) {
s.erase(s.begin());
q[C[i]].pop();
s.insert(mp(q[C[i]].front(), i + K));
}
else {
int x = prev(s.end())->se;
ans[x] = true;
s.erase(prev(s.end()));
q[C[i]].pop();
s.insert(mp(q[C[i]].front(), i + K));
}
}
for(int i=0; i<N+K; i++) {
WriteAdvice(ans[i]);
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
static int n;
static set<int> t, s;
void Assist(unsigned char *A, int N, int K, int R) {
n = N;
for(int i=0; i<K; i++) {
if(A[i]) s.insert(i);
t.insert(i);
}
for(int i = K; i < N + K; i++) {
int x = GetRequest();
if(t.find(x) == t.end()) {
t.insert(x);
int y = *s.begin();
s.erase(y);
t.erase(y);
PutBack(y);
}
if(A[i]) s.insert(x);
}
}
# | 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... |