#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 BL = 320;
int bt = 9;
for (int x: vec){
if (x==-1) continue;
int blID = x / BL;
for (int j = bt; j >= 0; j--){
if (((blID >> j) & 1)) WriteAdvice(1);
else WriteAdvice(0);
}
int iID = x - blID * BL;
for (int j = bt; j >= 0; j--){
if (((iID >> 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 BL = 320;
int bt = 9;
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 blID = CC[l++];
int iID = CC[l++];
int idx = blID * BL + iID;
PutBack(idx);
on[idx] = 0;
on[req] = 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
47904 KB |
Output is correct |
2 |
Correct |
21 ms |
47960 KB |
Output is correct |
3 |
Correct |
23 ms |
47984 KB |
Output is correct |
4 |
Correct |
26 ms |
48240 KB |
Output is correct |
5 |
Incorrect |
24 ms |
48228 KB |
Error - advice is too long |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
49308 KB |
Output is correct |
2 |
Correct |
107 ms |
52968 KB |
Output is correct |
3 |
Correct |
247 ms |
63088 KB |
Output is correct |
4 |
Correct |
294 ms |
65576 KB |
Output is correct |
5 |
Correct |
288 ms |
64672 KB |
Output is correct |
6 |
Correct |
237 ms |
62400 KB |
Output is correct |
7 |
Correct |
194 ms |
60684 KB |
Output is correct |
8 |
Correct |
231 ms |
62212 KB |
Output is correct |
9 |
Correct |
284 ms |
63780 KB |
Output is correct |
10 |
Correct |
188 ms |
60260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
57932 KB |
Output is correct |
2 |
Correct |
202 ms |
60320 KB |
Output is correct |
3 |
Correct |
185 ms |
60188 KB |
Output is correct |
4 |
Correct |
179 ms |
59564 KB |
Output is correct |
5 |
Correct |
159 ms |
57432 KB |
Output is correct |
6 |
Correct |
235 ms |
60096 KB |
Output is correct |
7 |
Correct |
197 ms |
59916 KB |
Output is correct |
8 |
Incorrect |
76 ms |
55668 KB |
Error - advice is too long |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
48132 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
210 ms |
60732 KB |
Output is partially correct - 1029820 bits used |
2 |
Correct |
217 ms |
60440 KB |
Output is partially correct - 989460 bits used |
3 |
Correct |
191 ms |
60348 KB |
Output is partially correct - 949960 bits used |
4 |
Correct |
184 ms |
60324 KB |
Output is partially correct - 949340 bits used |
5 |
Correct |
214 ms |
60172 KB |
Output is partially correct - 947480 bits used |
6 |
Correct |
194 ms |
60300 KB |
Output is partially correct - 949540 bits used |
7 |
Correct |
188 ms |
60308 KB |
Output is partially correct - 948120 bits used |
8 |
Correct |
216 ms |
60256 KB |
Output is partially correct - 951120 bits used |
9 |
Correct |
185 ms |
60312 KB |
Output is partially correct - 950440 bits used |
10 |
Correct |
275 ms |
64816 KB |
Output is partially correct - 1490160 bits used |