# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
18777 | suhgyuho_william | 최후의 만찬 (IOI12_supper) | C++98 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include "advisor.h"
#include <queue>
#include <vector>
#include <stdlib.h>
using namespace std;
int ans[100010],tc[100010];
bool check[100010];
#define pp pair<int,pair<int,int> >
priority_queue<pp> q;
int next[100010];
vector<int> paint[100010];
void ComputeAdvice(int *C, int N, int K, int M) {
int i,j;
int t,cnt;
pp top;
for(i=0; i<N; i++) tc[i] = C[i];
for(i=N; i>=1; i--) C[i] = C[i-1];
t = 2; cnt = 1;
while(true){
if(t-1 >= K-1) break;
cnt++;
t *= 2;
}
for(i=1; i<=N; i++){
if(check[C[i]] == false && C[i] < K){
check[C[i]] = true;
q.push(make_pair(i,make_pair(C[i],C[i])));
}
paint[C[i]].push_back(i);
}
for(i=0; i<K; i++){
if(check[i]) continue;
check[i] = true;
q.push(make_pair(999999999,make_pair(i,i)));
}
for(i=0; i<N; i++){
t = paint[i].size();
for(j=0; j<t-1; j++){
next[paint[i][j]] = paint[i][j+1];
}
if(t != 0){
next[paint[i][t-1]] = 999999999;
}
}
for(i=1; i<=N; i++){
t = C[i];
if(check[t]){
ans[i] = 999999999;
continue;
}
top = q.top();
q.pop();
ans[i] = top.second.second;
check[top.second.first] = false;
check[t] = true;
q.push(make_pair(next[i],make_pair(t,top.second.second)));
}
for(i=1; i<=N; i++){
if(ans[i] == 999999999) WriteAdvice(0);
else WriteAdvice(1);
}
for(i=1; i<=N; i++){
if(ans[i] == 999999999) continue;
t = ans[i];
for(j=1; j<=cnt; j++){
WriteAdvice(t%2);
t /= 2;
}
}
for(i=0; i<N; i++) C[i] = tc[i];
}
#include "assistant.h"
#include <stdio.h>
#include <queue>
#include <vector>
#include <stdlib.h>
using namespace std;
int a[100010];
int change[100010];
int bucket[100010];
void Assist(unsigned char *A, int N, int K, int R) {
int i,j;
int t,cnt;
int sum,rear;
for(i=R; i>=1; i--) A[i] = A[i-1];
t = 2; cnt = 1;
while(true){
if(t-1 >= K-1) break;
cnt++;
t *= 2;
}
for(i=1; i<=N; i++){
change[i] = A[i];
}
rear = N;
for(i=0; i<K; i++) bucket[i] = i;
for(i=1; i<=N; i++){
a[i] = GetRequest();
if(change[i] == 0) continue;
t = 1; sum = 0;
for(j=rear+1; j<=rear+cnt; j++){
sum += (t*A[j]);
t *= 2;
}
PutBack(bucket[sum]);
bucket[sum] = a[i];
rear += cnt;
}
}