#include <bits/stdc++.h>
#define f first
#define s second
#include "advisor.h"
using namespace std;
int endK[25005], endN[100005];
int endpos[100005];
deque<int> pos[100005];
set<int> pos2[100005];
void ComputeAdvice(int *C, int N, int K, int M) {
set<pair<int,int>> scaffold;
for (int i = 0; i < K; i++) scaffold.insert({i,-1});
for (int i = 0; i < N; i++) endN[i] = -1;
for (int i = 0; i < N; i++) pos[C[i]].push_back(i);
for (int i = 0; i < N; i++) pos[i].push_back(1e9);
for (int i = 0; i < N; i++) {
for (auto j : pos[i]) pos2[i].insert(j);
}
set<pair<int,int>> cur;
for (int i = 0; i < K; i++) cur.insert({pos[i][0],i});
for (int i = 0; i < N; i++) {
string tmp;
if (cur.find({pos[C[i]][0],C[i]}) != cur.end()) {
cur.erase({pos[C[i]][0],C[i]});
pos[C[i]].pop_front();
cur.insert({pos[C[i]][0],C[i]});
} else {
pos[C[i]].pop_front();
int tar = (*cur.rbegin()).s;
auto tmp = *scaffold.lower_bound({tar,INT_MIN});
if (tmp.s == -1) endK[tmp.f] = i;
else endN[tmp.s] = i;
scaffold.erase(scaffold.find(tmp));
scaffold.insert({C[i],i});
cur.erase(*cur.rbegin());
cur.insert({pos[C[i]][0],C[i]});
}
}
for (auto i : scaffold) {
if (i.s == -1) endK[i.f] = 1e8;
else endN[i.s] = 1e8;
}
for (int i = 0; i < K; i++) {
endpos[i] = endK[i];
int tmp = *pos2[i].lower_bound(0);
WriteAdvice(tmp > endK[i]);
}
for (int i = 0; i < N; i++) {
if (endN[i] == -1) {
int tmp = *pos2[C[i]].upper_bound(i);
WriteAdvice(tmp > endpos[i]);
} else {
int tmp = *pos2[C[i]].upper_bound(i);
WriteAdvice(tmp > endN[i]);
endpos[C[i]] = endN[i];
}
}
}
#include <bits/stdc++.h>
#define f first
#define s second
#include "assistant.h"
using namespace std;
deque<int> put;
int col[100005];
void Assist(unsigned char *A, int N, int K, int R) {
for (int i = 0; i < K; i++) if (A[i]) put.push_back(i);
for (int i = 0; i < K; i++) col[i] = 1;
for (int i = K; i < R; i++) {
int cur = GetRequest();
if (col[cur]) continue;
while (!col[put[0]]) put.pop_front();
PutBack(put[0]);
col[put[0]] = 0;
col[cur] = 1;
put.pop_front();
if (A[i]) put.push_back(cur);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
72500 KB |
Output is correct |
2 |
Runtime error |
45 ms |
72624 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
72 ms |
74408 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
182 ms |
87188 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
47 ms |
73640 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
234 ms |
90244 KB |
Execution killed with signal 11 |
2 |
Runtime error |
218 ms |
90424 KB |
Execution killed with signal 11 |
3 |
Runtime error |
216 ms |
90852 KB |
Execution killed with signal 11 |
4 |
Runtime error |
247 ms |
90940 KB |
Execution killed with signal 6 |
5 |
Runtime error |
205 ms |
90808 KB |
Execution killed with signal 11 |
6 |
Runtime error |
263 ms |
90780 KB |
Execution killed with signal 6 |
7 |
Runtime error |
218 ms |
90800 KB |
Execution killed with signal 11 |
8 |
Runtime error |
209 ms |
90704 KB |
Execution killed with signal 6 |
9 |
Runtime error |
249 ms |
90692 KB |
Execution killed with signal 11 |
10 |
Runtime error |
190 ms |
90696 KB |
Execution killed with signal 11 |