#include <bits/stdc++.h>
#include "advisor.h"
#define pb push_back
using namespace std;
const int MM = 2e6 + 5;
bool onn[MM];
vector <int> st[MM];
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i=N-1;i>=0;i--){
st[C[i]].pb(i);
}
set <pair<int,int> > stt;
for (int i=0;i<K;i++){
onn[i] = 1;
int val = 0;
if (!st[i].size()) val=1e9;
else val=st[i].back();
stt.insert({val,i});
}
int i;
vector <int> vec;
for (i = 0; i < N; i++) {
int req = C[i];
if (onn[req]) {
vec.pb(-1);
int val = 0;
if (!st[req].size()) val=1e9;
else val=st[req].back();
stt.erase(stt.find({val,req}));
while (st[req].size() && st[req].back() <= i){
st[req].pop_back();
}
val = 0;
if (!st[req].size()) val=1e9;
else val=st[req].back();
stt.insert({val,req});
continue;
}
int idx=(--stt.end())->second; stt.erase(--stt.end());
vec.pb(idx);
onn[idx] = 0;
onn[req] = 1;
while (st[req].size() && st[req].back() <= i){
st[req].pop_back();
}
int val = 0;
if (!st[req].size()) val=1e9;
else val=st[req].back();
stt.insert({val,req});
}
int bt = log2(N);
for (int x: vec){
if (x==-1) continue;
for (int j = bt; j >= 0; j--){
if (((x >> j) & 1)) WriteAdvice(1);
else WriteAdvice(0);
}
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
int CC[2000005];
bool on[2000005];
void Assist(unsigned char *A, int N, int K, int R) {
int bt = log2(N);
int id=0;
for (int i = 0; i < R; i += bt + 1){
for (int j = i; j <= i + bt; j++){
if (A[j] == 1) CC[id] |= (1<<(bt-(j-i)));
}
id+=1;
}
for (int i=0;i<K;i++) on[i] = 1;
int i;
int l = 0;
for (i = 0; i < N; i++) {
int req = GetRequest();
if (on[req]) {
continue;
}
int idx = CC[l++];
PutBack(idx);
on[idx] = 0;
on[req] = 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
49592 KB |
Output is correct |
2 |
Correct |
17 ms |
49748 KB |
Output is correct |
3 |
Correct |
17 ms |
50016 KB |
Output is correct |
4 |
Correct |
20 ms |
50084 KB |
Output is correct |
5 |
Correct |
26 ms |
50396 KB |
Output is correct |
6 |
Correct |
25 ms |
50240 KB |
Output is correct |
7 |
Correct |
20 ms |
50064 KB |
Output is correct |
8 |
Correct |
27 ms |
50380 KB |
Output is correct |
9 |
Correct |
25 ms |
50320 KB |
Output is correct |
10 |
Correct |
22 ms |
50316 KB |
Output is correct |
11 |
Correct |
22 ms |
50356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
50832 KB |
Output is correct |
2 |
Correct |
83 ms |
53528 KB |
Output is correct |
3 |
Correct |
183 ms |
62188 KB |
Output is correct |
4 |
Correct |
237 ms |
65844 KB |
Output is correct |
5 |
Correct |
226 ms |
65204 KB |
Output is correct |
6 |
Correct |
224 ms |
63548 KB |
Output is correct |
7 |
Correct |
167 ms |
60224 KB |
Output is correct |
8 |
Correct |
174 ms |
61688 KB |
Output is correct |
9 |
Correct |
258 ms |
64364 KB |
Output is correct |
10 |
Correct |
155 ms |
59864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
134 ms |
58096 KB |
Output is correct |
2 |
Correct |
162 ms |
60112 KB |
Output is correct |
3 |
Correct |
159 ms |
61048 KB |
Output is correct |
4 |
Correct |
195 ms |
60572 KB |
Output is correct |
5 |
Correct |
125 ms |
58488 KB |
Output is correct |
6 |
Correct |
157 ms |
61052 KB |
Output is correct |
7 |
Correct |
156 ms |
60692 KB |
Output is correct |
8 |
Correct |
213 ms |
67128 KB |
Output is correct |
9 |
Correct |
102 ms |
57768 KB |
Output is correct |
10 |
Correct |
181 ms |
61128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
47804 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
166 ms |
60392 KB |
Output is partially correct - 875347 bits used |
2 |
Correct |
211 ms |
60384 KB |
Output is partially correct - 841041 bits used |
3 |
Correct |
158 ms |
60044 KB |
Output is partially correct - 807466 bits used |
4 |
Correct |
166 ms |
60036 KB |
Output is partially correct - 806939 bits used |
5 |
Correct |
164 ms |
59972 KB |
Output is partially correct - 805358 bits used |
6 |
Correct |
158 ms |
60056 KB |
Output is partially correct - 807109 bits used |
7 |
Correct |
174 ms |
59900 KB |
Output is partially correct - 805902 bits used |
8 |
Correct |
157 ms |
60048 KB |
Output is partially correct - 808452 bits used |
9 |
Correct |
175 ms |
59984 KB |
Output is partially correct - 807874 bits used |
10 |
Correct |
207 ms |
65952 KB |
Output is partially correct - 1266636 bits used |