//In the name of God
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll a[maxn], ok[maxn], ptr[maxn], prio[maxn], ind[maxn];
vector<ll> vec[maxn];
set<pll> st;
void ComputeAdvice(int *c, int n, int k, int m){
ll lg = 0;
while((1 << lg) < k) lg++;
for(ll i = 0; i < k; i++){
a[i] = i;
ind[i] = i;
ok[i] = 1;
}
for(ll i = 0; i < n; i++){
vec[c[i]].pb(i);
}
for(ll i = 0; i < n; i++){
vec[i].pb(n);
vec[i].pb(n);
}
for(ll i = 0; i < n; i++){
prio[i] = vec[i][ptr[i]++];
if(i < k) st.insert(Mp(-prio[i], i));
}
for(ll i = 0; i < n; i++){
if(ok[c[i]]){
st.erase(Mp(-prio[c[i]], c[i]));
prio[c[i]] = vec[c[i]][ptr[c[i]]++];
st.insert(Mp(-prio[c[i]], c[i]));
continue;
}
ll j = st.begin()->S;
st.erase(st.begin());
ok[j] = 0;
ok[c[i]] = 1;
ind[c[i]] = ind[j];
prio[c[i]] = vec[c[i]][ptr[c[i]]++];
st.insert(Mp(-prio[c[i]], c[i]));
for(ll o = 0; o < lg; o++){
WriteAdvice((ind[j] >> o) & 1);
//cout << ((ind[j] >> o) & 1);
}
}
}
/*int main(){
int c[100], n, k, m;
cin >> n >> k >> m;
for(ll i = 0; i < n; i++){
cin >> c[i];
}
ComputeAdvice(c, n, k, m);
}*/
//In the name of God
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll a[maxn], ok[maxn];
void Assist(unsigned char *A, int n, int k, int r) {
ll lg = 0;
while((1 << lg) < k) lg++;
ll ptr = 0;
for(ll i = 0; i < k; i++){
a[i] = i;
ok[i] = 1;
}
for(ll i = 0; i < n; i++){
ll x = GetRequest();
if(ok[x]) continue;
ll y = 0;
for(ll j = 0; j < lg; j++){
if(A[ptr++] == 1) y += (1 << j);
}
PutBack(a[y]);
ok[a[y]] = 0;
a[y] = x;
ok[a[y]] = 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
5748 KB |
Output is correct |
2 |
Correct |
5 ms |
5476 KB |
Output is correct |
3 |
Correct |
6 ms |
5812 KB |
Output is correct |
4 |
Correct |
10 ms |
5904 KB |
Output is correct |
5 |
Correct |
9 ms |
5908 KB |
Output is correct |
6 |
Correct |
15 ms |
6224 KB |
Output is correct |
7 |
Correct |
10 ms |
6172 KB |
Output is correct |
8 |
Correct |
18 ms |
6548 KB |
Output is correct |
9 |
Correct |
17 ms |
6404 KB |
Output is correct |
10 |
Correct |
15 ms |
6556 KB |
Output is correct |
11 |
Correct |
15 ms |
6596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
7120 KB |
Output is correct |
2 |
Correct |
126 ms |
13092 KB |
Output is correct |
3 |
Correct |
338 ms |
25904 KB |
Output is correct |
4 |
Correct |
241 ms |
20436 KB |
Output is correct |
5 |
Correct |
295 ms |
22264 KB |
Output is correct |
6 |
Correct |
322 ms |
23228 KB |
Output is correct |
7 |
Correct |
317 ms |
23168 KB |
Output is correct |
8 |
Correct |
317 ms |
23184 KB |
Output is correct |
9 |
Correct |
152 ms |
18604 KB |
Output is correct |
10 |
Correct |
285 ms |
23332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
234 ms |
19052 KB |
Output is correct |
2 |
Correct |
316 ms |
23352 KB |
Output is correct |
3 |
Correct |
293 ms |
23004 KB |
Output is correct |
4 |
Correct |
326 ms |
22208 KB |
Output is correct |
5 |
Correct |
239 ms |
20804 KB |
Output is correct |
6 |
Correct |
354 ms |
23028 KB |
Output is correct |
7 |
Correct |
284 ms |
23012 KB |
Output is correct |
8 |
Correct |
366 ms |
26776 KB |
Output is correct |
9 |
Correct |
203 ms |
21068 KB |
Output is correct |
10 |
Correct |
320 ms |
22868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
6060 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
298 ms |
22476 KB |
Output is partially correct - 772365 bits used |
2 |
Correct |
306 ms |
22688 KB |
Output is partially correct - 742095 bits used |
3 |
Correct |
306 ms |
22472 KB |
Output is partially correct - 712470 bits used |
4 |
Correct |
318 ms |
22872 KB |
Output is partially correct - 712005 bits used |
5 |
Correct |
302 ms |
22520 KB |
Output is partially correct - 710610 bits used |
6 |
Correct |
297 ms |
22516 KB |
Output is partially correct - 712155 bits used |
7 |
Correct |
295 ms |
22352 KB |
Output is partially correct - 711090 bits used |
8 |
Correct |
292 ms |
22408 KB |
Output is partially correct - 713340 bits used |
9 |
Correct |
302 ms |
22484 KB |
Output is partially correct - 712830 bits used |
10 |
Correct |
381 ms |
25728 KB |
Output is partially correct - 1117620 bits used |