# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991032 | lalig777 | Last supper (IOI12_supper) | C++14 | 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 "advisor.h"
#include <iostream>
#include <vector>
#include <unordered_set>
#include <queue>
using namespace std;
void ComputeAdvice(vector<int>C, int N, int K, int M){
vector<int>orden(N, 0);
for (int i=0; i<N; i++) orden[C[i]]++;
for (int i=0; i<K; i++){
if (orden[i]==0) WriteAdvice(0);
else WriteAdvice(1);
}
for (int i=0; i<N; i++){
int x=C[i];
orden[x]--;
if (orden[x]==0) WriteAdvice(0);
else WriteAdvice(1);
}return;
}
#include "assistant.h"
#include <iostream>
#include <vector>
#include <unordered_set>
#include <queue>
using namespace std;
void Assist(vector<unsigned char>A, int N, int K, int R){
queue<int>away;
unordered_set<int>current;
for (int i=0; i<K; i++){
current.insert(i);
if (A[i]=='0') away.push(i);
}
for (int i=0; i<N; i++){
int follow=GetRequest();
char x=A[i+K];
if (!(current.find(follow)!=current.end())){
int remov=-1;
if (away.empty()) remov=*current.begin();
else{
remov=away.front();
away.pop();
}
PutBack(remov);
current.erase(remov);
current.insert(follow);
}if (x=='0') away.push(follow);
}return;
}