#include "advisor.h"
#include <iostream>
#include <utility>
#include <cassert>
#include <map>
#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 time == o.time ? col < o.col : time < o.time;
}
};
const int maxN = 1e5 + 326;
bool has[maxN], advice[maxN << 1];
map<int, Obj> mp;
deque<int> dq[maxN];
void ComputeAdvice(int *C, int N, int K, int M) {
fill(has, has + K, 1);
cout << "Helloooo\n";
for(int i = 0; i < N; i++){
dq[C[i]].push_back(i);
}
cout << "Hello\n";
for(int i = 0; i < K; i++){
int furt = dq[i].size() ? dq[i].front() : maxN;
mp[furt] = Obj(i - K, i);
}
cout << "Hello\n";
for(int i = 0; i < N; i++){ //thirteen bits lol
if(has[C[i]]){
int furt = dq[C[i]].size() ? dq[i].front() : maxN;
mp.erase(mp.find(furt));
} else {
auto it = mp.rbegin();
advice[it->S.time + K] = 1;
mp.erase(mp.find(it->F));
has[it->S.col] = false;
}
while(dq[C[i]].size() && dq[C[i]].front() <= i) dq[C[i]].pop_front();
int furt = dq[C[i]].size() ? dq[i].front() : maxN;
mp[furt] = Obj(i + K, C[i]);
has[C[i]] = true;
}
cout << "Hello\n";
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;
}
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;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
68472 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
129 ms |
137708 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
166 ms |
140140 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
130 ms |
137452 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
156 ms |
140652 KB |
Execution killed with signal 6 |
2 |
Runtime error |
157 ms |
140780 KB |
Execution killed with signal 6 |
3 |
Runtime error |
153 ms |
140908 KB |
Execution killed with signal 6 |
4 |
Runtime error |
151 ms |
140908 KB |
Execution killed with signal 6 |
5 |
Runtime error |
156 ms |
141036 KB |
Execution killed with signal 6 |
6 |
Runtime error |
155 ms |
141036 KB |
Execution killed with signal 6 |
7 |
Runtime error |
157 ms |
140780 KB |
Execution killed with signal 6 |
8 |
Runtime error |
166 ms |
141036 KB |
Execution killed with signal 6 |
9 |
Runtime error |
157 ms |
140996 KB |
Execution killed with signal 6 |
10 |
Runtime error |
157 ms |
142060 KB |
Execution killed with signal 6 |