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, 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 |
Correct |
1 ms |
508 KB |
Output is correct |
2 |
Incorrect |
0 ms |
516 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
1372 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
115 ms |
6704 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
924 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
134 ms |
7700 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
145 ms |
7904 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
153 ms |
8184 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
155 ms |
8240 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
141 ms |
8260 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
148 ms |
8304 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
139 ms |
8288 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
182 ms |
8264 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
143 ms |
8128 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
159 ms |
8168 KB |
Output is correct - 200000 bits used |