#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *a, int n, int k, int ___) {
vector<int> solution;
vector<int> when(n);
int tt = 0;
vector<vector<int>> nxt(n, vector<int> (1, n + 1));
for (int i = n - 1; i >= 0; i--) {
nxt[a[i]].push_back(i);
}
set<int> active_guys;
set<pair<int, int>> nxt_time;
for (int i = 0; i < k; i++) {
active_guys.insert(i);
nxt_time.insert({nxt[i].back(), i});
}
for (int i = 0; i < k; i++) {
when[i] = tt++;
solution.push_back(0);
}
for (int i = 0; i < n; i++) {
assert((int) nxt_time.size() == k);
if (!nxt_time.count({nxt[a[i]].back(), a[i]})) {
auto it = nxt_time.end(); it--;
int guy = it->second;
nxt_time.erase(it);
nxt_time.insert({nxt[a[i]].back(), a[i]});
when[a[i]] = tt++;
solution.push_back(0);
} else {
solution[when[a[i]]] = 1;
}
nxt[a[i]].pop_back();
assert(nxt_time.count({i, a[i]}));
nxt_time.erase({i, a[i]});
nxt_time.insert({i, a[i]});
}
assert((int) nxt_time.size() == k);
for (auto &x : solution) {
WriteAdvice(x);
}
return;
for (auto &x : solution) {
cout << x << " ";
}
cout << "\n";
exit(0);
WriteAdvice(0);
WriteAdvice(1);
WriteAdvice(2);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *a, int n, int k, int r) {
set<int> act, skip;
int ptr = 0;
for (int i = 0; i < k; i++) {
act.insert(i);
if (a[ptr++] == 0) {
skip.insert(i);
}
}
for (int i = 0; i < k; i++) {
int nxt = GetRequest();
if (act.count(nxt)) continue;
assert(!skip.empty());
int x = *skip.begin();
skip.erase(x);
assert(act.count(x));
act.erase(x);
act.insert(x);
assert(ptr < r);
if (a[ptr++] == 0) {
skip.insert(i);
}
PutBack(x);
}
//exit(0);
return;
/**
int i;
set<int> give;
for (int i = )
for (i = 0; i < n; i++) {
int req = GetRequest();
if (req >= k)
PutBack(req % k);
}
**/
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:29:11: warning: unused variable 'guy' [-Wunused-variable]
29 | int guy = it->second;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
552 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
1856 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
90 ms |
11808 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1156 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
114 ms |
13668 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
126 ms |
14148 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
126 ms |
14468 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
117 ms |
14552 KB |
Error - Not putting back color when it is not on the scaffold |
5 |
Incorrect |
121 ms |
14612 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
175 ms |
14476 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
117 ms |
14504 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
144 ms |
14472 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
132 ms |
14580 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
125 ms |
14488 KB |
Error - Putting back a color that is not on the scaffold |