#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();
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;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
68344 KB |
Output is correct |
2 |
Correct |
55 ms |
68420 KB |
Output is correct |
3 |
Correct |
53 ms |
68520 KB |
Output is correct |
4 |
Correct |
61 ms |
68584 KB |
Output is correct |
5 |
Correct |
71 ms |
68488 KB |
Output is correct |
6 |
Correct |
74 ms |
68616 KB |
Output is correct |
7 |
Correct |
56 ms |
68532 KB |
Output is correct |
8 |
Correct |
72 ms |
68360 KB |
Output is correct |
9 |
Correct |
76 ms |
68488 KB |
Output is correct |
10 |
Correct |
68 ms |
68896 KB |
Output is correct |
11 |
Correct |
71 ms |
68488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
68652 KB |
Output is correct |
2 |
Correct |
1028 ms |
70276 KB |
Output is correct |
3 |
Execution timed out |
2508 ms |
73808 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2579 ms |
72216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
68684 KB |
Output is correct |
2 |
Correct |
71 ms |
68656 KB |
Output is correct |
3 |
Correct |
73 ms |
68556 KB |
Output is correct |
4 |
Correct |
78 ms |
68400 KB |
Output is correct |
5 |
Correct |
67 ms |
68556 KB |
Output is correct |
6 |
Correct |
74 ms |
68956 KB |
Output is correct |
7 |
Correct |
70 ms |
68656 KB |
Output is correct |
8 |
Correct |
72 ms |
68528 KB |
Output is correct |
9 |
Correct |
72 ms |
68872 KB |
Output is correct |
10 |
Correct |
63 ms |
68956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2594 ms |
72756 KB |
Time limit exceeded |
2 |
Execution timed out |
2524 ms |
73236 KB |
Time limit exceeded |
3 |
Execution timed out |
2516 ms |
73148 KB |
Time limit exceeded |
4 |
Execution timed out |
2586 ms |
73220 KB |
Time limit exceeded |
5 |
Execution timed out |
2574 ms |
73612 KB |
Time limit exceeded |
6 |
Execution timed out |
2511 ms |
73216 KB |
Time limit exceeded |
7 |
Execution timed out |
2598 ms |
73216 KB |
Time limit exceeded |
8 |
Execution timed out |
2522 ms |
73348 KB |
Time limit exceeded |
9 |
Execution timed out |
2538 ms |
73148 KB |
Time limit exceeded |
10 |
Execution timed out |
2587 ms |
73348 KB |
Time limit exceeded |