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