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>
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
#include "advisor.h"
#include "assistant.h"
void ComputeAdvice(int *c, int n, int k, int m) {
vector <vector <int> > ne(n), del(n);
for (int i = 0; i < n; i++) {
ne[c[i]].pb(i);
}
for (int i = 0; i < n; i++) ne[i].pb(n);
set <pii> s;
for (int i = 0; i < k; i++) s.insert({*ne[i].begin(), i});
for (int i = 0; i < n; i++) {
int x = c[i];
if (s.find({i, x}) != s.end()) s.erase({i, x});
else {
int y = (--s.end()) -> S;
s.erase(--s.end());
del[y].pb(i);
}
s.insert({*upper_bound(all(ne[x]), i), x});
}
vector <int> res(n+k, 0);
for (int i = 0; i < n; i++) del[i].pb(n+1);
for (int i = 0; i < k; i++) {
res[i] = (*del[i].begin() > *ne[i].begin());
}
for (int i = 0; i < n; i++) {
res[k+i] = (*upper_bound(all(del[c[i]]), i) > *upper_bound(all(ne[c[i]]), i));
}
for (int i = 0; i < n+k; i++) {
WriteAdvice(res[i]);
}
}
#include <bits/stdc++.h>
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
#include "advisor.h"
#include "assistant.h"
void Assist(unsigned char *a, int n, int k, int r) {
set <int> s, t;
for (int i = 0; i < k; i++) {
s.insert(i);
if (!a[i]) t.insert(i);
}
for (int i = 0; i < n; i++) {
int x = GetRequest();
if (s.find(x) == s.end()) {
int y = *t.begin();
s.erase(y);
t.erase(y);
s.insert(x);
PutBack(y);
}
if (!a[k+i]) t.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... |