#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *c, int n, int k, int m){
vector<int> occ[n];
for(int i = n-1;i>=0;i--){
occ[c[i]].push_back(i);
}
for(int i = 0;i<k;i++){
WriteAdvice(occ[i].empty());
}
for(int i = 0;i<n;i++){
occ[c[i]].pop_back();
WriteAdvice(occ[c[i]].empty());
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
struct BIT{
vector<int> bit;
int n;
BIT(int size){
n = size+5;
bit.assign(n,0);
}
void upd(int pos,int val){
for(++pos;pos < n;pos += pos & -pos){
bit[pos] += val;
}
}
int get(int pos){
int ret = 0;
for(++pos;pos > 0;pos -= pos & -pos){
ret += bit[pos];
}
return ret;
}
int get(int l,int r){
return get(r) - get(l-1);
}
int get_kth(int k){
int pos = 0;
for(int i = 20;i>=0;i--){
if( pos + (1<<i) < n && bit[pos + (1<<i)] < k){
k -= bit[pos + (1<<i)];
pos += (1<<i);
}
}
return pos;
}
};
void Assist(unsigned char *a, int n, int k, int r) {
srand(time(NULL));
set<int> s,now;
BIT bt(n);
int last = 0;
for(int i = 0;i<k;i++){
if(a[last++] == 1){
s.insert(i);
}
now.insert(i);
bt.upd(i,1);
}
assert(k > 3);
for (int i = 0; i < n; i++) {
int req = GetRequest();
if(now.count(req) == 0){
int num = bt.get_kth(rand()%k + 1);
if(s.size()){
num = *s.begin();
s.erase(s.begin());
}
now.erase(num);
bt.upd(num,-1);
PutBack(num);
now.insert(req);
bt.upd(req,1);
}
if(a[last++] == 1){
s.insert(req);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
636 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1460 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
8320 KB |
Output is correct |
2 |
Correct |
129 ms |
10276 KB |
Output is correct |
3 |
Correct |
122 ms |
10332 KB |
Output is correct |
4 |
Correct |
110 ms |
10160 KB |
Output is correct |
5 |
Incorrect |
98 ms |
8964 KB |
Output isn't correct - not an optimal way |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
920 KB |
Output is correct |
2 |
Correct |
7 ms |
1168 KB |
Output is correct |
3 |
Incorrect |
5 ms |
924 KB |
Output isn't correct - not an optimal way |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
9940 KB |
Output isn't correct - not an optimal way |
2 |
Correct |
130 ms |
10116 KB |
Output is correct - 122000 bits used |
3 |
Correct |
114 ms |
10324 KB |
Output is correct - 125000 bits used |
4 |
Correct |
120 ms |
10284 KB |
Output is correct - 125000 bits used |
5 |
Correct |
140 ms |
10296 KB |
Output is correct - 125000 bits used |
6 |
Correct |
115 ms |
10416 KB |
Output is correct - 125000 bits used |
7 |
Correct |
117 ms |
10548 KB |
Output is correct - 124828 bits used |
8 |
Correct |
145 ms |
10340 KB |
Output is correct - 124910 bits used |
9 |
Correct |
118 ms |
10356 KB |
Output is correct - 125000 bits used |
10 |
Incorrect |
120 ms |
11392 KB |
Output isn't correct - not an optimal way |