| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 70041 | Abelyan | 최후의 만찬 (IOI12_supper) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int N=100006;
int a[N],han[N],mp[N];
bool pas[N];
void ComputeAdvice(int *c, int n, int k, int m) {
for (int i=n-1;i>=0;i--){
a[i]=mp[c[i]]-1;
if (mp[c[i]]==0)a[i]=2*n;
mp[c[i]]=i+1;
}
priority_queue<pair<int,int> > pq;
for (int i=0;i<k;i++){
if (mp[i]==0)mp[i]=2*N;
pq.push({mp[i],i});
}
for (int i=0;i<n;i++){
han[i]=pq.top().second;
pq.pop();
pq.push({a[i],c[i]});
}
vector<int> v;
for (int i=n-1;i>=0;i--){
if (pas[c[i]])v.push_back(1);
else v.push_back(0);
pas[han[i]]=false;
pas[c[i]]=true;
}
for (int i=k-1;i>=0;i--){
if (pas[i])v.push_back(1);
else v.push_back(0);
}
reverse(v.begin(),v.end());
for (int i=0;i<v.size();i++){
WriteAdvice(v[i]);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int N=100006;
queue<int> s;
bool onsc[N];
void Assist(unsigned char *A, int n, int k, int R) {
for (int i=0;i<k;i++){
if (!A[i])s.push(i);
onsc[i]=true;
}
for (int i=0;i<n;i++){
int k=GetRequest();
if (onsc[k])continue;
PutBack(s.top());
onsc[s.top()]=false;
s.pop();
if (!A[i+k])s.push(k);
}
}
