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,-1);
vi sweep(n,-1);
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, 4, 5, 2, 1, 3};
// ComputeAdvice(c, 6, 3, -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);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
516 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
1500 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
100 ms |
6700 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
924 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
123 ms |
7764 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
124 ms |
7884 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
130 ms |
8304 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
120 ms |
8220 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
132 ms |
8172 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
127 ms |
8180 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
123 ms |
8276 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
124 ms |
8232 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
126 ms |
8300 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
149 ms |
8332 KB |
Output isn't correct - not an optimal way |