#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
void ComputeAdvice(int *C, int N, int K, int M)
{
//ugh lol ok lets brute force.
int B = 32 - __builtin_clz(K);
FOR(i, 0, N)
{
FORD(j, B, 0)
{
WriteAdvice((C[i] & (1 << j)) ? 1 : 0);
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 100013
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
set<pii> alive;
int arr[MAXN];
int rt[MAXN], pos[MAXN];
void Assist(unsigned char *A, int N, int K, int R)
{
int B = 32 - __builtin_clz(K);
FOR(i, 0, N)
{
int num = 0;
FOR(j, i * B, (i + 1) * B)
{
num *= 2; if (A[j]) num++;
}
arr[i] = num;
// cerr << "arr " << i << " = " << num << endl;
}
FOR(i, 0, N)
{
pos[i] = N;
}
FORD(i, N, 0)
{
// cerr << "pos " << arr[i] << " set to " << i << endl;
rt[i] = pos[arr[i]];
pos[arr[i]] = i;
}
// FOR(i, 0, N)
// {
// cerr << pos[i] << ' ';
// }
// cerr << endl;
FOR(i, 0, K)
{
// cerr << pos[i] << ' ';
alive.insert({pos[i], i});
}
// cerr << endl;
FOR(i, 0, N)
{
int cur = GetRequest();
if (alive.find({pos[cur], cur}) == alive.end())
{
pii p = *alive.rbegin();
alive.erase(prev(alive.end()));
PutBack(p.se);
alive.insert({pos[cur], cur});
}
alive.erase({pos[cur], cur});
pos[cur] = rt[i];
alive.insert({pos[cur], cur});
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
764 KB |
Output is correct |
2 |
Incorrect |
4 ms |
892 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
1964 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
312 ms |
12456 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
772 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
388 ms |
15336 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
391 ms |
15164 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
396 ms |
15304 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
389 ms |
15372 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
401 ms |
15376 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
392 ms |
15532 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
394 ms |
15248 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
390 ms |
15388 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
388 ms |
15420 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
377 ms |
15356 KB |
Output isn't correct - not an optimal way |