#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ALL(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return ((ull) rng()) % (r - l + 1) + l;}
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return mask & (-mask);}
ll pop_cnt(ll mask){return __builtin_popcountll(mask);}
ll ctz(ll mask){return __builtin_ctzll(mask);}
ll clz(ll mask){return __builtin_clzll(mask);}
ll logOf(ll mask){return 63 - clz(mask);}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b){a = b; return true;}
return false;
}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b){a = b; return true;}
return false;
}
template <class T>
void printArr(T& a, string separator = " ", string finish = "\n", ostream& out = cout){
for(auto i: a) out << i << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
void ComputeAdvice(int *C, int n, int k, int m){
vector<vector<int>> color(n);
for(int i = 0; i<n; ++i) color[C[i]].push_back(i);
for(int i = 0; i<n; ++i) color[i].push_back(n);
set<pair<int, int>> S;
for(int i = 0; i<k; ++i) S.insert({color[i][0], i});
vector<int> oo;
for(int i = 0; i<n; ++i){
auto it = S.begin();
if ((*it).first == i){
pair<int, int> y = *it;
S.erase(it);
S.insert({*upper_bound(ALL(color[C[i]]), i), y.second});
}
else{
pair<int, int> y = *S.rbegin();
S.erase(y);
oo.push_back(y.second);
S.insert({*upper_bound(ALL(color[C[i]]), i), y.second});
}
}
const int LOG_N = logOf(k * 2 - 1);
for(int i: oo){
for(int j = 0; j < LOG_N; ++j){
WriteAdvice(i % 2);
i /= 2;
}
}
}
// int main(void){
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// int C[] = {2, 0, 3, 0};
// ComputeAdvice(C, 4, 2, 1000);
// return 0;
// }
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ALL(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return ((ull) rng()) % (r - l + 1) + l;}
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return mask & (-mask);}
ll pop_cnt(ll mask){return __builtin_popcountll(mask);}
ll ctz(ll mask){return __builtin_ctzll(mask);}
ll clz(ll mask){return __builtin_clzll(mask);}
ll logOf(ll mask){return 63 - clz(mask);}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b){a = b; return true;}
return false;
}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b){a = b; return true;}
return false;
}
template <class T>
void printArr(T& a, string separator = " ", string finish = "\n", ostream& out = cout){
for(auto i: a) out << i << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
void Assist(unsigned char *A, int n, int k, int r){
const int LOG_N = logOf(k * 2);
vector<int> oo;
for(int i = 0; i < r; i += LOG_N){
int cur = 0;
for(int j = 0; j < LOG_N; ++j) if (A[i+j]){
cur += MASK(j);
}
oo.push_back(cur);
}
vector<int> scaffold(k);
set<int> S;
for(int i= 0; i<k; ++i) {
scaffold[i] = i;
S.insert(i);
}
reverse(ALL(oo));
for(int i = 0; i<n; ++i){
int j = GetRequest();
if (S.find(j) == S.end()){
int k = oo.back(); oo.pop_back();
S.erase(scaffold[k]);
PutBack(scaffold[k]);
scaffold[k] = j;
S.insert(scaffold[k]);
}
else{
}
}
}
// void PutBack(int T);
// int GetRequest();
// int main(void){
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
784 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 |
Correct |
16 ms |
2036 KB |
Output is correct |
2 |
Correct |
74 ms |
6652 KB |
Output is correct |
3 |
Correct |
267 ms |
16524 KB |
Output is correct |
4 |
Correct |
164 ms |
12260 KB |
Output is correct |
5 |
Correct |
200 ms |
13652 KB |
Output is correct |
6 |
Correct |
258 ms |
13832 KB |
Output is correct |
7 |
Correct |
206 ms |
14288 KB |
Output is correct |
8 |
Correct |
189 ms |
14144 KB |
Output is correct |
9 |
Correct |
98 ms |
11720 KB |
Output is correct |
10 |
Correct |
190 ms |
14628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
11848 KB |
Output is correct |
2 |
Correct |
196 ms |
14500 KB |
Output is correct |
3 |
Correct |
184 ms |
14532 KB |
Output is correct |
4 |
Correct |
185 ms |
14308 KB |
Output is correct |
5 |
Correct |
159 ms |
13256 KB |
Output is correct |
6 |
Correct |
186 ms |
14528 KB |
Output is correct |
7 |
Correct |
200 ms |
14552 KB |
Output is correct |
8 |
Correct |
227 ms |
16440 KB |
Output is correct |
9 |
Correct |
155 ms |
13448 KB |
Output is correct |
10 |
Correct |
191 ms |
14532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1056 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
205 ms |
14128 KB |
Output is partially correct - 772365 bits used |
2 |
Correct |
200 ms |
14288 KB |
Output is partially correct - 742095 bits used |
3 |
Correct |
190 ms |
14560 KB |
Output is partially correct - 712470 bits used |
4 |
Correct |
196 ms |
14400 KB |
Output is partially correct - 712005 bits used |
5 |
Correct |
199 ms |
14164 KB |
Output is partially correct - 710610 bits used |
6 |
Correct |
201 ms |
14436 KB |
Output is partially correct - 712155 bits used |
7 |
Correct |
198 ms |
14432 KB |
Output is partially correct - 711090 bits used |
8 |
Correct |
224 ms |
14328 KB |
Output is partially correct - 713340 bits used |
9 |
Correct |
191 ms |
14592 KB |
Output is partially correct - 712830 bits used |
10 |
Correct |
250 ms |
16452 KB |
Output is partially correct - 1117620 bits used |