이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "advisor.h"
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;
void debug_out(){cerr << endl;}
template<typename H, typename... T>
void debug_out(H h, T... t){
cerr << h << ' ';
debug_out(t...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 1e5 + 10;
int n, k, m, res[maxn << 1], lst[maxn];
vector<int> idx[maxn];
void ComputeAdvice(int *C, int N, int K, int M) {
n = N;
k = K;
m = M;
for (int i = 0; i < n; i++){
idx[C[i]].push_back(i);
}
set<pii> st;
for (int i = 0; i < n; i++){
idx[i].push_back(n);
reverse(all(idx[i]));
}
memset(lst, -1, sizeof lst);
for (int i = 0; i < k; i++){
st.insert({idx[i].back(), i});
lst[i] = i;
}
for (int i = 0; i < n; i++){
if (lst[C[i]] != -1){
st.erase({i, C[i]});
res[lst[C[i]]] = 1;
}
else{
auto it = st.end();
it--;
pii tmp = *it;
st.erase(it);
lst[tmp.S] = -1;
}
idx[C[i]].pop_back();
st.insert({idx[C[i]].back(), C[i]});
lst[C[i]] = k+i;
}
for (int i = 0; i < k+n; i++){
WriteAdvice(res[i]);
}
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;
/*void debug_out(){cerr << endl;}
template<typename H, typename... T>
void debug_out(H h, T... t){
cerr << h << ' ';
debug_out(t...);
}*/
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 1e5 + 10;
bool mark[maxn];
void Assist(unsigned char *A, int N, int K, int R) {
int n = N;
int k = K;
vector<int> del;
for (int i = 0; i < k; i++){
mark[i] = true;
if (A[i] == 0) del.push_back(i);
}
for (int i = 0; i < n; i++){
int tmp = GetRequest();
if (!mark[tmp]){
PutBack(del.back());
mark[del.back()] = false;
del.pop_back();
}
mark[tmp] = true;
if (A[k+i] == 0) del.push_back(tmp);
}
}
# | 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... |