이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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]});
}
}
컴파일 시 표준 에러 (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... |