using namespace std;
#include <bits/stdc++.h>
#include "advisor.h"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<bool> vb;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
// void WriteAdvice(int x) {
// cout << x << " ";
// }
void ComputeAdvice(int *c, int n, int k, int m) {
set<int> scaffold;
rep(i,0,k) scaffold.insert(i);
vi advice(2*n, 0);
vi added(n, 0);
rep(i,0,k) added[i] = i;
vi nextOccurenceOfColor(n,-1e9);
vi sweep(n,-1e9);
for (int i = n - 1; i >= 0; i--) {
nextOccurenceOfColor[i] = sweep[c[i]];
sweep[c[i]] = i;
}
priority_queue<pair<int,int>> pq;
rep(i,0,k) pq.push({-sweep[i], i});
// for (auto k : scaffold) cout << k << " "; cout << endl;
rep(i,0,n) {
int color = c[i];
added[color] = n+i;
if (scaffold.find(color) != scaffold.end()) {
continue;
}
pair<int,int> res = pq.top(); pq.pop();
// cout << "popped " << res.first << ", "<< res.second << endl;
int toRemove = res.second;
advice[added[toRemove]] = 1;
// cout << "advice at " << added[toRemove] << endl;
scaffold.erase(toRemove);
scaffold.insert(c[i]);
pq.push({-nextOccurenceOfColor[i], c[i]});
// for (auto k : scaffold) cout << k << " "; cout << endl;
}
rep(i,0,2*n) WriteAdvice(advice[i]);
}
//
// int main() {
// int c[] ={0, 1, 2, 1, 2, 1, 0, 2};
// ComputeAdvice(c, 8, 2, -1);
// }
using namespace std;
#include <bits/stdc++.h>
#include "assistant.h"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<bool> vb;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
void Assist(unsigned char *a, int n, int k, int r) {
set<int> scaffold;
rep(i,0,k) scaffold.insert(i);
vector<int> advice(2*n);
rep(i,0,2*n) advice[i] = a[i];
queue<int> q;
rep(i,0,k) if (advice[i] == 1) q.push(i);
rep(i,0,n) {
int nextColor = GetRequest();
if (scaffold.find(nextColor) == scaffold.end()) {
int rem = q.front(); q.pop();
PutBack(rem);
scaffold.erase(rem);
scaffold.insert(nextColor);
}
if (advice[n + i] == 1) {
q.push(nextColor);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
476 KB |
Output is correct |
2 |
Incorrect |
0 ms |
516 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
1380 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
92 ms |
6704 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
996 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
125 ms |
7624 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
129 ms |
7908 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
112 ms |
8188 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
117 ms |
8256 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
127 ms |
8304 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
114 ms |
8196 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
114 ms |
8296 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
125 ms |
8176 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
120 ms |
8156 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
127 ms |
8172 KB |
Output isn't correct - not an optimal way |