#include "advisor.h"
#include <iostream>
#include <utility>
#include <cassert>
#include <set>
#include <deque>
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
struct Obj{
int time, col;
Obj(int time = 0, int col = 0): time(time), col(col){}
const bool operator<(const Obj &o) const {
return col == o.col ? time < o.time : col < o.col;
}
};
const int maxN = 1e5 + 326;
bool has[maxN], advice[maxN << 1];
set <pair<int, Obj>> st;
deque<int> dq[maxN];
void ComputeAdvice(int *C, int N, int K, int M) {
fill(has, has + K, 1);
for(int i = 0; i < N; i++){
dq[C[i]].push_back(i);
}
for(int i = 0; i < K; i++){
int furt = dq[i].size() ? dq[i].front() : maxN;
st.insert({furt, Obj(i - K, i)});
}
int bc = 0, key;
while((1 << bc) < N + 1) bc++;
for(int i = 0; i < N; i++){ //thirteen bits lol
key = -1;
if(has[C[i]]){
int furt = dq[C[i]].size() ? dq[C[i]].front() : maxN;
st.erase(st.lower_bound({furt, Obj(-maxN, C[i])}));
} else {
auto it = --st.end();
advice[it->S.time + K] = 1;
st.erase(st.find({it->F, it->S}));
has[it->S.col] = false;
key = it->S.col;
}
if(key == -1) key = (1 << bc) - 1;
while(dq[C[i]].size() && dq[C[i]].front() <= i) dq[C[i]].pop_front();
int furt = dq[C[i]].size() ? dq[C[i]].front() : maxN;
st.insert({furt, Obj(i, C[i])});
has[C[i]] = true;
for(int j = 0; j < bc; j++) WriteAdvice((key >> j) & 1);
}
//for(int i = 0; i < N + K; i++) WriteAdvice(advice[i]);
}
#include <iostream>
#include <set>
#include <utility>
#include <queue>
#include <cassert>
#define pii pair<int,int>
#define F first
#define S second
#include "assistant.h"
using namespace std;
bool cur[101010], inq[101010];
void Assist(unsigned char *A, int N, int K, int R) {
//assert(R == N + K);
for(int i = 0; i < K; i++){
cur[i] = true;
if(A[i]) inq[i] = true;
}
int bc = 0, key;
while((1 << bc) < N + 1) bc++;
for(int i = 0; i < N; i++){
int r = GetRequest();
key = 0;
for(int j = (i + 1) * bc - 1; j >= (i) * bc; j--){
key = key * 2 + A[j];
}
if(key != (1 << bc) - 1){
PutBack(key);
}
/*
if(!cur[r]){
for(int j = 0; j < N; j++){
if(cur[j] && inq[j]){
cur[j] = false;
inq[j] = false;
PutBack(j);
break;
}
}
}
cur[r] = true;
if(A[i + K]) inq[r] = true;
*/
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:24:7: warning: unused variable 'r' [-Wunused-variable]
24 | int r = GetRequest();
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
68516 KB |
Output is correct |
2 |
Correct |
52 ms |
68384 KB |
Output is correct |
3 |
Correct |
61 ms |
68496 KB |
Output is correct |
4 |
Correct |
61 ms |
68624 KB |
Output is correct |
5 |
Correct |
69 ms |
69028 KB |
Output is correct |
6 |
Correct |
68 ms |
69028 KB |
Output is correct |
7 |
Correct |
67 ms |
69028 KB |
Output is correct |
8 |
Correct |
78 ms |
68900 KB |
Output is correct |
9 |
Correct |
72 ms |
68900 KB |
Output is correct |
10 |
Correct |
69 ms |
69284 KB |
Output is correct |
11 |
Correct |
69 ms |
69028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
69688 KB |
Output is correct |
2 |
Correct |
268 ms |
75008 KB |
Output is correct |
3 |
Correct |
538 ms |
84380 KB |
Output is correct |
4 |
Correct |
507 ms |
82092 KB |
Output is correct |
5 |
Correct |
538 ms |
82060 KB |
Output is correct |
6 |
Correct |
542 ms |
82788 KB |
Output is correct |
7 |
Correct |
532 ms |
83396 KB |
Output is correct |
8 |
Correct |
464 ms |
81448 KB |
Output is correct |
9 |
Correct |
517 ms |
81824 KB |
Output is correct |
10 |
Correct |
534 ms |
83792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
452 ms |
79848 KB |
Output is correct |
2 |
Incorrect |
139 ms |
73132 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
53 ms |
68344 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
522 ms |
82564 KB |
Output is partially correct - 1700000 bits used |
2 |
Correct |
530 ms |
82620 KB |
Output is partially correct - 1700000 bits used |
3 |
Correct |
537 ms |
82572 KB |
Output is partially correct - 1700000 bits used |
4 |
Correct |
528 ms |
83072 KB |
Output is partially correct - 1700000 bits used |
5 |
Correct |
527 ms |
82724 KB |
Output is partially correct - 1700000 bits used |
6 |
Correct |
544 ms |
83024 KB |
Output is partially correct - 1700000 bits used |
7 |
Correct |
525 ms |
82636 KB |
Output is partially correct - 1697263 bits used |
8 |
Correct |
550 ms |
82908 KB |
Output is partially correct - 1700000 bits used |
9 |
Correct |
528 ms |
82904 KB |
Output is partially correct - 1700000 bits used |
10 |
Correct |
520 ms |
82712 KB |
Output is partially correct - 1700000 bits used |