#include "advisor.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 100000;
int ans[N], ans_pos[N], ans_ptr;
int cnt[N];
vector<int> pos[N];
void ComputeAdvice(int *c, int n, int k, int m)
{
LoopR (i,0,n)
pos[c[i]].push_back(i);
priority_queue<pii> pq;
Loop (i,0,k) {
pq.push({pos[i].size()? pos[i].back(): n, i});
cnt[i] = 1;
ans_pos[i] = ans_ptr++;
}
Loop (i,0,n) {
if (cnt[c[i]]) {
cnt[c[i]]++;
continue;
}
auto [_, x] = pq.top();
ans[ans_pos[x]] = cnt[x];
//cerr << "ans[" << ans_pos[x] << "] = " << cnt[x] << '\n';
cnt[x] = 0;
pq.pop();
pos[c[i]].pop_back();
pq.push({pos[c[i]].size()? pos[c[i]].back(): n, c[i]});
cnt[c[i]] = 1;
ans_pos[c[i]] = ans_ptr++;
}
Loop (i,0,n) {
if (cnt[i]) {
ans[ans_pos[i]] = cnt[i];
//cerr << "ans[" << ans_pos[i] << "] = " << cnt[i] << '\n';
cnt[i] = 0;
}
}
Loop (i,0,ans_ptr)
Loop (j,0,ans[i])
WriteAdvice(i&1);
}
#include "assistant.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 100000;
int lck[N];
vector<int> zero_lck;
int n, k, r;
unsigned char *a;
int ap;
int get_bs()
{
int x = a[ap];
int tmp = ap;
while (ap < r && a[ap] == x)
++ap;
return ap - tmp;
}
void Assist(unsigned char *_a, int _n, int _k, int _r)
{
a = _a;
n = _n; k = _k; r = _r;
assert(n+k == r);
Loop (i,0,k) {
if (!(lck[i] = get_bs() - 1))
zero_lck.push_back(i);
//cerr << "lck[" << i << "] = " << lck[i] << '\n';
}
Loop (i,0,n) {
int x = GetRequest();
if (lck[x]) {
if (!--lck[x])
zero_lck.push_back(x);
//cerr << "lck[" << x << "] = " << lck[x] << '\n';
} else {
int y = zero_lck.back();
zero_lck.pop_back();
PutBack(y);
if (!(lck[x] = get_bs() - 1))
zero_lck.push_back(x);
//cerr << "lck[" << x << "] = " << lck[x] << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2960 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3080 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
3736 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
9120 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
3252 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
73 ms |
10544 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Incorrect |
82 ms |
10548 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
91 ms |
10640 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
68 ms |
10736 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
66 ms |
10672 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
74 ms |
10644 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
70 ms |
10632 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
75 ms |
10884 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
73 ms |
10676 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Correct |
74 ms |
11788 KB |
Output is correct - 125000 bits used |