#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e5+7;
int kiedy[LIM], nxt[LIM], on[LIM], uzyte[2*LIM];
void ComputeAdvice(int *c, int n, int k, int m) {
rep(i, n) kiedy[i]=n;
for(int i=n-1; i>=0; --i) {
nxt[i]=kiedy[c[i]];
kiedy[c[i]]=i;
}
priority_queue<pair<int,pair<int,int>>>q;
rep(i, k) {
on[i]=1;
q.push({kiedy[i], {i, i}});
}
rep(i, n) {
if(!on[c[i]]) {
int a=q.top().nd.st, b=q.top().nd.nd; q.pop();
uzyte[b]=1;
on[a]=0;
}
on[c[i]]=1;
q.push({nxt[i], {c[i], i+k}});
}
rep(i, n+k) WriteAdvice(uzyte[i]);
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e5+7;
int xd[LIM];
void Assist(unsigned char *A, int n, int k, int r) {
queue<int>q;
rep(i, k) {
xd[i]=1;
if(A[i]) q.push(i);
}
rep(i, n) {
int a=GetRequest();
if(!xd[a]) {
int p=q.front(); q.pop();
PutBack(p);
xd[a]=1;
xd[p]=0;
}
if(A[k+i]) q.push(a);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
496 KB |
Output is correct |
2 |
Correct |
1 ms |
496 KB |
Output is correct |
3 |
Correct |
3 ms |
604 KB |
Output is correct |
4 |
Correct |
3 ms |
796 KB |
Output is correct |
5 |
Correct |
3 ms |
936 KB |
Output is correct |
6 |
Correct |
3 ms |
944 KB |
Output is correct |
7 |
Correct |
4 ms |
1040 KB |
Output is correct |
8 |
Correct |
6 ms |
880 KB |
Output is correct |
9 |
Correct |
5 ms |
936 KB |
Output is correct |
10 |
Correct |
4 ms |
1072 KB |
Output is correct |
11 |
Correct |
5 ms |
936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1168 KB |
Output is correct |
2 |
Correct |
38 ms |
3640 KB |
Output is correct |
3 |
Correct |
79 ms |
7212 KB |
Output is correct |
4 |
Correct |
75 ms |
6364 KB |
Output is correct |
5 |
Correct |
56 ms |
6324 KB |
Output is correct |
6 |
Correct |
66 ms |
6404 KB |
Output is correct |
7 |
Correct |
76 ms |
7256 KB |
Output is correct |
8 |
Correct |
60 ms |
5676 KB |
Output is correct |
9 |
Correct |
55 ms |
6396 KB |
Output is correct |
10 |
Correct |
77 ms |
7084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
4600 KB |
Output is correct |
2 |
Correct |
68 ms |
7120 KB |
Output is correct |
3 |
Correct |
69 ms |
7156 KB |
Output is correct |
4 |
Correct |
84 ms |
7072 KB |
Output is correct |
5 |
Correct |
63 ms |
7060 KB |
Output is correct |
6 |
Correct |
71 ms |
7196 KB |
Output is correct |
7 |
Correct |
83 ms |
7084 KB |
Output is correct |
8 |
Correct |
69 ms |
6568 KB |
Output is correct |
9 |
Correct |
61 ms |
6956 KB |
Output is correct |
10 |
Correct |
72 ms |
7096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
928 KB |
Output is correct |
2 |
Correct |
6 ms |
936 KB |
Output is correct |
3 |
Correct |
4 ms |
944 KB |
Output is correct |
4 |
Correct |
5 ms |
944 KB |
Output is correct |
5 |
Correct |
3 ms |
944 KB |
Output is correct |
6 |
Correct |
5 ms |
944 KB |
Output is correct |
7 |
Correct |
5 ms |
936 KB |
Output is correct |
8 |
Correct |
4 ms |
936 KB |
Output is correct |
9 |
Correct |
5 ms |
936 KB |
Output is correct |
10 |
Correct |
4 ms |
1072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
81 ms |
6108 KB |
Output is correct - 120000 bits used |
2 |
Correct |
69 ms |
5980 KB |
Output is correct - 122000 bits used |
3 |
Correct |
73 ms |
6188 KB |
Output is correct - 125000 bits used |
4 |
Correct |
73 ms |
6068 KB |
Output is correct - 125000 bits used |
5 |
Correct |
71 ms |
6000 KB |
Output is correct - 125000 bits used |
6 |
Correct |
70 ms |
5980 KB |
Output is correct - 125000 bits used |
7 |
Correct |
69 ms |
6004 KB |
Output is correct - 124828 bits used |
8 |
Correct |
78 ms |
6036 KB |
Output is correct - 124910 bits used |
9 |
Correct |
68 ms |
6200 KB |
Output is correct - 125000 bits used |
10 |
Correct |
69 ms |
5584 KB |
Output is correct - 125000 bits used |