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;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
const int N = (int)1e5 + 15;
int Q[N];
bool ban[N];
int sol[N];
void ComputeAdvice(int *C, int n, int k, int m) {
for(int i = 0 ; i < n; i ++ ){
Q[i] = C[i];
}
for(int i = 0 ; i < n; i ++ ){
ban[Q[i]]=true;
}
for(int i = 0 ; i < k ; i ++ ){
if(ban[i])
WriteAdvice(1);
else
WriteAdvice(0);
}
for(int i = 0 ; i < n; i ++ ){
ban[i] = false;
}
for(int i = n - 1; i >= 0 ; i -- ){
if(ban[C[i]]){
sol[i] = 1;
}
else{
sol[i] = 0;
}
ban[C[i]]=true;
}
for(int i = 0 ; i < n; i ++ ){
WriteAdvice(sol[i]);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
const int N = (int)1e5 + 10;
void Assist(unsigned char *A, int n, int k, int r) {
set<int> free, need;
for(int i = 0 ; i < k ; i ++ ){
if(A[i] == 0){
free.insert(i);
}
else{
need.insert(i);
}
}
int req;
for(int i = 0 ; i < n; i ++ ){
req = GetRequest();
if(!free.count(req) && !need.count(req)){
if(!free.empty()){
auto it = free.begin();
int id = *it;
free.erase(it);
PutBack(id);
if(A[i + k] == 0){
free.insert(req);
}
else{
need.insert(req);
}
}
else{
auto it = need.begin();
int id = *it;
need.erase(it);
PutBack(id);
if(A[i + k] == 0){
free.insert(req);
}
else{
need.insert(req);
}
}
}
else{
if(A[i + k] == 0){
need.erase(req);
free.insert(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... |