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 "advisor.h"
#include <cmath>
#include <map>
#include <set>
#include <iostream>
using namespace std;
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 "assistant.h"
#include <cmath>
#include <map>
#include <set>
#include <iostream>
using namespace std;
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);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |