#include "advisor.h"
#include <bits/stdc++.h>
#define R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
unordered_map<int, vector<int>> mpa;
R(N) {
int a = C[i];
mpa[a].push_back(i);
}
unordered_set<int> val;
R(K) {
val.insert(i);
}
vector<int> nxt(N, INT_MAX);
priority_queue<ii> que;
R(K) {
if (!mpa[i].size()) que.push({INT_MAX, i});
else {
que.push({mpa[i][0], i});
nxt[i] = mpa[i][0];
}
}
bool init[K] {};
bool rem[N] {};
vector<int> last(N, -1);
R(N) {
int a = C[i];
last[a] = i;
if (!val.count(a)) {
while (nxt[que.top().second] != que.top().first) {
que.pop();
}
auto b = que.top();
que.pop();
int c = b.second;
if (last[c] == -1) init[c] = true;
else rem[last[c]] = true;
}
auto it = upper_bound(mpa[a].begin(), mpa[a].end(), i);
if (it == mpa[a].end()) {
que.push({INT_MAX, a});
nxt[a] = INT_MAX;
}
else {
que.push({*it, a});
nxt[a] = *it;
}
}
R(K) {
if (init[i]) WriteAdvice(1);
else WriteAdvice(0);
}
R(N) {
if (rem[i]) WriteAdvice(1);
else WriteAdvice(0);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#define R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
queue<int> rem;
unordered_set<int> val;
R(K) {
cerr << "A " << (int)(A[i]) << endl;
}
cerr << "N\n";
R(N) {
cerr << "A " << (int)(A[K + i]) << endl;
}
R(K) {
val.insert(i);
if (A[i]) rem.push(i);
}
R(N) {
int a = GetRequest();
if (!val.count(a)) {
val.insert(a);
PutBack(rem.front());
val.erase(rem.front());
rem.pop();
}
if (A[K + i]) {
rem.push(a);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
508 KB |
Output is correct |
2 |
Incorrect |
2 ms |
516 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
62 ms |
1848 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
432 ms |
10396 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
1172 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
563 ms |
12048 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
530 ms |
12660 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
545 ms |
12852 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
552 ms |
13072 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
516 ms |
13028 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
543 ms |
12948 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
551 ms |
12892 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
557 ms |
12880 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
565 ms |
12956 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
545 ms |
16092 KB |
Output is correct - 125000 bits used |