#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less_equal<long long>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key #of elements less than x
// find_by_order kth element
using ll=long long;
using ld=long double;
using pii=pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET(v,x) lower_bound(ALL(v),x)-v.begin()
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
namespace {
const int maxn=2e5+5;
int nxt[maxn],lst[maxn];
bool in[maxn],del[maxn];
}
void ComputeAdvice(int *C, int n, int k, int M) {
priority_queue<pii> pq;
REP(i,n) lst[i]=n,in[i]=0;
for(int i=n-1;i>=0;i--){
nxt[i]=lst[C[i]];
lst[C[i]]=i;
}
REP(i,k) pq.push({lst[i],i}),in[i]=1,lst[i]=i;
REP(i,n){
if(!in[C[i]]){
while(!in[pq.top().s]) pq.pop();
int z=pq.top().s;
pq.pop();
del[lst[z]]=1;
in[z]=0;
}
in[C[i]]=1;
pq.push({nxt[i],C[i]});
lst[C[i]]=k+i;
}
REP(i,n+k) WriteAdvice(del[i]);
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less_equal<long long>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key #of elements less than x
// find_by_order kth element
using ll=long long;
using ld=long double;
using pii=pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET(v,x) lower_bound(ALL(v),x)-v.begin()
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
namespace {
const int maxn=2e5+5;
bool in[maxn];
}
void Assist(unsigned char *A, int n, int k, int R) {
vector<int> v;
REP(i,n) in[i]=0;
REP(i,k){
in[i]=1;
if(A[i]) v.pb(i);
}
REP(i,n){
int x=GetRequest();
if(!in[x]){
assert(sz(v));
int z=v.back();
v.pop_back();
in[z]=0,in[x]=1;
PutBack(z);
}
if(A[i+k]){
v.pb(x);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
512 KB |
Output is correct |
2 |
Correct |
0 ms |
520 KB |
Output is correct |
3 |
Correct |
1 ms |
648 KB |
Output is correct |
4 |
Correct |
2 ms |
672 KB |
Output is correct |
5 |
Correct |
3 ms |
824 KB |
Output is correct |
6 |
Correct |
3 ms |
960 KB |
Output is correct |
7 |
Correct |
3 ms |
1100 KB |
Output is correct |
8 |
Correct |
3 ms |
960 KB |
Output is correct |
9 |
Correct |
3 ms |
940 KB |
Output is correct |
10 |
Correct |
4 ms |
1096 KB |
Output is correct |
11 |
Correct |
3 ms |
952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1124 KB |
Output is correct |
2 |
Correct |
27 ms |
3416 KB |
Output is correct |
3 |
Correct |
61 ms |
6948 KB |
Output is correct |
4 |
Correct |
48 ms |
5600 KB |
Output is correct |
5 |
Correct |
50 ms |
5604 KB |
Output is correct |
6 |
Correct |
54 ms |
5792 KB |
Output is correct |
7 |
Correct |
62 ms |
6932 KB |
Output is correct |
8 |
Correct |
51 ms |
5148 KB |
Output is correct |
9 |
Correct |
47 ms |
5556 KB |
Output is correct |
10 |
Correct |
57 ms |
6872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
4100 KB |
Output is correct |
2 |
Correct |
57 ms |
6984 KB |
Output is correct |
3 |
Correct |
57 ms |
6796 KB |
Output is correct |
4 |
Correct |
59 ms |
7044 KB |
Output is correct |
5 |
Correct |
54 ms |
6940 KB |
Output is correct |
6 |
Correct |
57 ms |
6820 KB |
Output is correct |
7 |
Correct |
57 ms |
6916 KB |
Output is correct |
8 |
Correct |
61 ms |
5724 KB |
Output is correct |
9 |
Correct |
54 ms |
6868 KB |
Output is correct |
10 |
Correct |
57 ms |
6892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
932 KB |
Output is correct |
2 |
Correct |
3 ms |
960 KB |
Output is correct |
3 |
Correct |
3 ms |
824 KB |
Output is correct |
4 |
Correct |
3 ms |
812 KB |
Output is correct |
5 |
Correct |
3 ms |
824 KB |
Output is correct |
6 |
Correct |
3 ms |
952 KB |
Output is correct |
7 |
Correct |
3 ms |
940 KB |
Output is correct |
8 |
Correct |
4 ms |
824 KB |
Output is correct |
9 |
Correct |
3 ms |
964 KB |
Output is correct |
10 |
Correct |
3 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
5680 KB |
Output is correct - 120000 bits used |
2 |
Correct |
57 ms |
5716 KB |
Output is correct - 122000 bits used |
3 |
Correct |
61 ms |
5620 KB |
Output is correct - 125000 bits used |
4 |
Correct |
55 ms |
5712 KB |
Output is correct - 125000 bits used |
5 |
Correct |
57 ms |
5888 KB |
Output is correct - 125000 bits used |
6 |
Correct |
55 ms |
5796 KB |
Output is correct - 125000 bits used |
7 |
Correct |
56 ms |
5592 KB |
Output is correct - 124828 bits used |
8 |
Correct |
56 ms |
5700 KB |
Output is correct - 124910 bits used |
9 |
Correct |
59 ms |
5672 KB |
Output is correct - 125000 bits used |
10 |
Correct |
55 ms |
4676 KB |
Output is correct - 125000 bits used |