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 <bits/stdc++.h>
#include "advisor.h"
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
int bt = log2(N);
// cout<<"bt ="<<bt<<endl;
for (int i=0;i<N;i++){
int x = C[i];
for (int j = bt; j >= 0; j--){
if (((x >> j) & 1)) WriteAdvice(1);
else WriteAdvice(0);
}
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
const int MM = 2e6 + 5;
int CC[MM];
bool on[MM];
set <int> st[MM];
void Assist(unsigned char *A, int N, int K, int R) {
int bt = log2(N);
// cout<<bt<<endl;
int id=0;
for (int i = 0; i < R; i += bt + 1){
for (int j = i; j <= i + bt; j++){
if (A[j] == 1) CC[id] |= (1<<(bt-(j-i)));
}
id+=1;
}
for (int i=id-1;i>=0;i--){
st[CC[i]].insert(i);
}
set <pair<int,int> > stt;
for (int i=0;i<K;i++){
on[i] = 1;
int val = 0;
if (!st[i].size()) val=1e9;
else val=*st[i].begin();
stt.insert({val,i});
}
int i;
for (i = 0; i < N; i++) {
int req = GetRequest();
if (on[req]) {
int val = 0;
if (!st[req].size()) val=1e9;
else val=*st[req].begin();
stt.erase(stt.find({val,req}));
while (st[req].size() && *st[req].begin() <= i){
st[req].erase(st[req].begin());
}
val = 0;
if (!st[req].size()) val=1e9;
else val=*st[req].begin();
stt.insert({val,req});
continue;
}
int idx=(--stt.end())->second;
PutBack(idx);
on[idx] = 0;
stt.erase(--stt.end());
on[req] = 1;
while (st[req].size() && *st[req].begin() <= i){
st[req].erase(st[req].begin());
}
int val = 0;
if (!st[req].size()) val=1e9;
else val=*st[req].begin();
stt.insert({val,req});
}
}
# | 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... |