#include "advisor.h"
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define uni(a) a.resize(unique(iter(a)));
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
using pii = pair<int, int>;
int sz;
void trans(int num){
for(int i = 0; i < sz; i++){
if(1 << i & num) WriteAdvice(1);
else WriteAdvice(0);
}
}
void ComputeAdvice(int *C, int n, int k, int M){
sz = __lg(k) + 1;
vector<int> table(k);
for(int i = 0; i < k; i++) table[i] = i;
vector<queue<int>> pos(n);
for(int i = 0; i < n; i++){
pos[C[i]].push(i);
}
for(int i = 0; i < n; i++) pos[i].push(n);
set<pii> st;
map<int, int> tp;
for(int i = 0; i < n; i++) tp[i] = -1;
for(int i = 0; i < k; i++){
st.insert(mp(pos[i].front(), i));
tp[i] = i;
}
for(int i = 0; i < n; i++){
int c = C[i];
pos[c].pop();
if(tp[c] != -1){
st.erase(mp(i, c));
st.insert(mp(pos[c].front(), c));
continue;
}
int rm = st.rbegin()->S;
st.erase(prev(st.end()));
trans(tp[rm]);
tp[c] = tp[rm];
tp[rm] = -1;
st.insert(mp(pos[c].front(), c));
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define uni(a) a.resize(unique(iter(a)));
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
using pii = pair<int, int>;
namespace{
int sz;
}
int ap = 0;
int trans(unsigned char *A){
int ans = 0;
for(int i = 0; i < sz; i++){
if(A[ap + i]) ans |= 1 << i;
}
ap += sz;
return ans;
}
void Assist(unsigned char *A, int n, int k, int m){
sz = __lg(k) + 1;
vector<int> table(k);
vector<bool> ok(n);
for(int i = 0; i < k; i++) table[i] = i, ok[i] = true;
for(int i = 0; i < n; i++){
int c = GetRequest();
if(ok[c]) continue;
int r = trans(A);
PutBack(table[r]);
ok[table[r]] = false;
ok[c] = true;
table[r] = c;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
488 KB |
Output is correct |
2 |
Correct |
2 ms |
616 KB |
Output is correct |
3 |
Correct |
4 ms |
1256 KB |
Output is correct |
4 |
Correct |
7 ms |
2700 KB |
Output is correct |
5 |
Correct |
13 ms |
4316 KB |
Output is correct |
6 |
Correct |
18 ms |
4428 KB |
Output is correct |
7 |
Correct |
8 ms |
4272 KB |
Output is correct |
8 |
Correct |
17 ms |
4436 KB |
Output is correct |
9 |
Correct |
17 ms |
4468 KB |
Output is correct |
10 |
Correct |
13 ms |
4564 KB |
Output is correct |
11 |
Correct |
18 ms |
4412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
8252 KB |
Output is correct |
2 |
Correct |
169 ms |
39372 KB |
Output is correct |
3 |
Correct |
510 ms |
80700 KB |
Output is correct |
4 |
Correct |
389 ms |
77644 KB |
Output is correct |
5 |
Correct |
437 ms |
78736 KB |
Output is correct |
6 |
Correct |
451 ms |
79108 KB |
Output is correct |
7 |
Correct |
481 ms |
79364 KB |
Output is correct |
8 |
Correct |
421 ms |
68788 KB |
Output is correct |
9 |
Correct |
318 ms |
75304 KB |
Output is correct |
10 |
Correct |
445 ms |
79348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
354 ms |
63800 KB |
Output is correct |
2 |
Correct |
476 ms |
79296 KB |
Output is correct |
3 |
Correct |
415 ms |
79256 KB |
Output is correct |
4 |
Correct |
405 ms |
79076 KB |
Output is correct |
5 |
Correct |
362 ms |
77432 KB |
Output is correct |
6 |
Correct |
410 ms |
79372 KB |
Output is correct |
7 |
Correct |
406 ms |
79204 KB |
Output is correct |
8 |
Correct |
524 ms |
80896 KB |
Output is correct |
9 |
Correct |
314 ms |
77984 KB |
Output is correct |
10 |
Correct |
415 ms |
79540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
3592 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
432 ms |
79412 KB |
Output is partially correct - 772365 bits used |
2 |
Correct |
474 ms |
79356 KB |
Output is partially correct - 742095 bits used |
3 |
Correct |
418 ms |
79304 KB |
Output is partially correct - 712470 bits used |
4 |
Correct |
434 ms |
79480 KB |
Output is partially correct - 712005 bits used |
5 |
Correct |
440 ms |
79400 KB |
Output is partially correct - 710610 bits used |
6 |
Correct |
418 ms |
79516 KB |
Output is partially correct - 712155 bits used |
7 |
Correct |
503 ms |
79324 KB |
Output is partially correct - 711090 bits used |
8 |
Correct |
415 ms |
79248 KB |
Output is partially correct - 713340 bits used |
9 |
Correct |
430 ms |
79396 KB |
Output is partially correct - 712830 bits used |
10 |
Correct |
497 ms |
80960 KB |
Output is partially correct - 1117620 bits used |