# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
288080 | ToMmyDong | 최후의 만찬 (IOI12_supper) | C++11 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define ALL(i) i.begin(), i.end()
#define SZ(i) int(i.size())
#define X first
#define Y second
#ifdef tmd
#define debug(...) fprintf(stderr,"#%d-(%s)=",__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y) {cerr<<x<<",";_do(y...);}
template<typename IT> ostream& __printRng (ostream& os, IT bg, IT ed) {
for (IT it=bg;it!=ed;it++) {
if (it == bg) os << "{" << *it;
else os << "," << *it;
}
return os << "}";
}
template<typename T> ostream& operator << (ostream& os, const vector<T> &vec) {
return __printRng(os, ALL(vec));
}
template<typename T, typename S> ostream& operator << (ostream& os, const pair<T,S> &pa) {
return os << "{" << pa.X << "," << pa.Y << "}";
}
#else
#define debug(...)
#endif
#include "assistant.h"
void Assist(unsigned char *a, int n, int k, int r) {
vector<int> c(n);
for (int i=0, ptr=0; i<n; i++) {
for (int j=0; j<20; j++) {
if (a[ptr++]) c[i] += (1<<j);
}
}
vector<int> nxt(n);
vector<int> lst(n, n);
for (int i=n-1; i>=0; i--) {
nxt[i] = lst[c[i]];
lst[c[i]] = i;
}
priority_queue<pii> pq;
set<int> st;
for (int i=0; i<k; i++) {
pq.emplace(pii(lst[i], i));
st.insert(i);
debug(lst[i], i);
}
for (int i=0; i<n; i++) {
int req = GetRequest();
assert(c[i] == req);
if (!st.count(req)) {
pii cur = pq.top();
pq.pop();
debug(cur);
debug(nxt[i], req);
PutBack(cur.Y);
st.erase(cur.Y);
st.insert(req);
pq.emplace(nxt[i], req);
}
}
}