# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
514831 | andrei_boaca | 최후의 만찬 (IOI12_supper) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
typedef pair<int,int> pii;
bool useful[200005];
int isthere[200005];
multiset<int> s;
deque<int> poz[200005];
int INF=1e9;
void ComputeAdvice(int *C, int N, int K, int M)
{
for(int i=0;i<K;i++)
poz[i].push_back(i);
for(int j=0;j<N;j++)
poz[C[j]].push_back(j+K);
for(int i=0;i<=N+K;i++)
useful[i]=0;
for(int i=0;i<K;i++)
{
isthere[i]=i+1;
poz[i].pop_front();
if(poz[i].empty())
s.insert(INF);
else
s.insert(poz[i].front());
}
for(int i=0;i<N;i++)
{
int nr=C[i];
if(isthere[nr])
{
useful[isthere[nr]-1]=1;
int p=poz[nr].front();
s.erase(s.find(p));
}
else
{
auto it=prev(s.end());
s.erase(it);
int p=(*it);
if(p<N&&p>0)
isthere[C[p]]=0;
}
isthere[nr]=poz[nr].front()+1;
poz[nr].pop_front();
if(poz[nr].empty())
s.insert(INF);
else
s.insert(poz[nr].front());
}
for(int i=0;i<N+K;i++)
WriteAdvice(useful[i]);
}