This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// That's How much we have in common
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef pair<int, int> pii;
void ComputeAdvice(int *C, int n, int k, int M) {
assert(n + k <= M);
vector<int> A(n + k, 0);
for(int i = 0; i < k; i++) A[i] = i;
for(int i = 0; i < n; i++) A[i + k] = C[i];
vector<int> LA(n, n + k), nx(n + k, 0);
vector<int> inp(n + k + 1, 0);
for(int i = n + k - 1; i >= 0; i--){
nx[i] = LA[A[i]];
inp[nx[i]] = i;
LA[A[i]] = i;
}
set<pii> st;
for(int i = 0; i < k; i++) st.insert({nx[i], A[i]});
vector<int> ans(n + k, 0);
for(int i = k; i < n + k; i++){
if(st.count({i, A[i]})){
ans[inp[i]] = 1;
st.erase({i, A[i]});
} else {
st.erase(--st.end());
}
st.insert({nx[i], A[i]});
}
for(auto x : ans) WriteAdvice(x);
//cerr << "! ";
//for(auto x : ans) cerr << x;
//cerr << '\n';
}
/*
4 2 65000
2 0 3 0
*/
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef pair<int, int> pii;
void Assist(unsigned char *As, int n, int k, int R) {
assert(R == n + k);
vector<int> A(n + k, 0);
for(int i = 0; i < k; i++) A[i] = i;
//for(int i = 0; i < n; i++) A[i + k] = C[i];
set<pii> st;
for(int i = 0; i < k; i++) st.insert({As[i], A[i]});
//cerr << "!! ";
int x;
for(int i = 0; i < n + k; i++){
x = As[i];
//cerr << x;
}
//cerr << '\n';
for(int i = k; i < n + k; i++){
A[i] = GetRequest();
if(st.count({1, A[i]})){
st.erase({1, A[i]});
} else {
//cerr << "? " << st.begin() -> F << ' ' << st.begin() -> S << '\n';
assert((st.begin() -> F == 0));
PutBack(st.begin() -> S);
st.erase(st.begin());
}
st.insert({As[i], A[i]});
}
}
Compilation message (stderr)
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:25:6: warning: variable 'x' set but not used [-Wunused-but-set-variable]
25 | int 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... |