# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
913830 | Muhammad_Aneeq | Last supper (IOI12_supper) | C++17 | 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 "grader.cpp"
#include <cmath>
#include <map>
#include <set>
#include <iostream>
void ComputeAdvice(int *C, int N, int K, int M)
{
for (int i=0;i<N;i++)
{
for (int j=0;j<=log2(N);j++)
{
if ((1<<j)&C[i])
WriteAdvice(1);
else
WriteAdvice(0);
}
}
}
#include "grader.h"
#include <cmath>
#include <map>
#include <set>
#include <iostream>
void Assist(unsigned char *A, int N, int K, int R)
{
int re[N]={};
int z=log2(N);
map<int,int>d;
set<int>res[N]={};
for (int i=0;i<N;i++)
{
for (int j=0;j<=z;j++)
re[i]+=(A[i*(z+1)+j]<<j);
res[re[i]].insert(i);
d[re[i]]++;
}
set<int>ind;
for (int i=0;i<K;i++)
ind.insert(i);
for (int i=0;i<N;i++)
{
int z=GetRequest();
d[z]--;
res[z].erase(i);
if (ind.find(z)!=ind.end())
continue;
int x=0;
int f=-1;
for (auto i:ind)
{
if (d[i]==0)
{
x=i;
f=-1;
break;
}
else
{
if (res[i].size()&&*begin(res[i])>f)
{
f=*begin(res[i]);
x=i;
}
}
}
PutBack(x);
ind.insert(z);
ind.erase(x);
res[i].erase(f);
}
}