#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;
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});
REP(i,n){
if(!in[C[i]]){
int z=pq.top().s;
pq.pop();
if(z<k) in[z]=0,del[z]=1;
else in[C[z-k]]=0,del[z-k]=1;
in[z]=0;
in[C[i]]=1;
pq.push({nxt[i],i+k});
}
}
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) {
queue<int> q;
REP(i,k){
in[i]=1;
if(A[i]) q.push(i);
}
REP(i,n){
int x=GetRequest();
if(!in[x]){
int z=q.front();
q.pop();
in[z]=0,in[x]=1;
PutBack(z);
}
if(A[i+k]) q.push(x);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
524 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1152 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
4764 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
924 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
53 ms |
5648 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
54 ms |
5712 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
53 ms |
5976 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
53 ms |
5692 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
56 ms |
6032 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
61 ms |
5692 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
52 ms |
5936 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
56 ms |
5864 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
54 ms |
5880 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
49 ms |
5856 KB |
Error - Putting back a color that is not on the scaffold |