#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 |
1 |
Correct |
0 ms |
568 KB |
Output is correct |
2 |
Correct |
1 ms |
640 KB |
Output is correct |
3 |
Correct |
2 ms |
684 KB |
Output is correct |
4 |
Incorrect |
3 ms |
660 KB |
Output isn't correct - not an optimal way |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1116 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
5360 KB |
Output is correct |
2 |
Correct |
86 ms |
6500 KB |
Output is correct |
3 |
Correct |
87 ms |
6432 KB |
Output is correct |
4 |
Correct |
88 ms |
6488 KB |
Output is correct |
5 |
Incorrect |
88 ms |
6220 KB |
Output isn't correct - not an optimal way |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
732 KB |
Output is correct |
2 |
Correct |
4 ms |
804 KB |
Output is correct |
3 |
Incorrect |
3 ms |
788 KB |
Output isn't correct - not an optimal way |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
87 ms |
6208 KB |
Output isn't correct - not an optimal way |
2 |
Correct |
116 ms |
6336 KB |
Output is correct - 122000 bits used |
3 |
Correct |
87 ms |
6436 KB |
Output is correct - 125000 bits used |
4 |
Correct |
88 ms |
6504 KB |
Output is correct - 125000 bits used |
5 |
Correct |
97 ms |
6532 KB |
Output is correct - 125000 bits used |
6 |
Correct |
93 ms |
6584 KB |
Output is correct - 125000 bits used |
7 |
Correct |
89 ms |
6448 KB |
Output is correct - 124828 bits used |
8 |
Correct |
110 ms |
6444 KB |
Output is correct - 124910 bits used |
9 |
Correct |
89 ms |
6532 KB |
Output is correct - 125000 bits used |
10 |
Incorrect |
83 ms |
6508 KB |
Output isn't correct - not an optimal way |