# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18743 | suhgyuho_william | Last supper (IOI12_supper) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include "advisor.h"
void ComputeAdvice(int *C, int N, int K, int M) {
int i,j;
int t,cnt;
t = cnt = 1;
while(true){
if(t >= 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 = cnt = 1;
while(true){
if(t >= 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));
}
}