#include "advisor.h"
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M){
auto get=[&](int x){for(int i=20;i>=0;i--)if(x&(1<<i))return i;};
vector<int>v,lastoc(N+1,N),on(N,0);
for(int i=0;i<N;i++,C++)v.pb(*C),lastoc[v.back()]=i;
vector<int>have;
priority_queue<pii>pq;
for(int i=0;i<K;i++)pq.push({lastoc[i],have.size()}),have.pb(i),on[i]=1;
if(K<N){
int mx=get(K);
for(auto i:v){
if(on[i])continue;
int pos=pq.top().s;
pq.pop();
on[have[pos]]=0;
for(int i=0;i<=mx;i++){
if(pos&(1<<i))WriteAdvice(1);
else WriteAdvice(0);
}
pq.push({lastoc[i],pos});
have[pos]=i;
on[i]=1;
}
}
else{
int mx=get(N);
for(auto i:v){
if(on[i])continue;
int pos=pq.top().s;
pq.pop();
on[have[pos]]=0;
for(int i=0;i<=mx;i++){
if(have[pos]&(1<<i))WriteAdvice(1);
else WriteAdvice(0);
}
pq.push({lastoc[i],pos});
have[pos]=i;
on[i]=1;
}
}
}
#include "assistant.h"
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
using namespace std;
void Assist(unsigned char *A, int N, int K, int R){
vector<int>have;
auto get2=[&](int x){for(int i=20;i>=0;i--)if(x&(1<<i))return i;};
vector<int>on(N,0),pos(N,0);
priority_queue<pii>pq;
for(int i=0;i<K;i++)have.pb(i),on[i]=1,pos[i]=i;
if(K<N){
int mx=get2(K);
for(int i=0;i<N;i++){
int x=GetRequest();
if(on[x])continue;
int val=0;
for(int j=0;j<=mx;j++,A++){
val+=((1<<j)*(*A));
}
PutBack(have[val]);
on[have[val]]=0;
have[val]=x;
on[x]=1;
}
}
else{
int mx=get2(N);
for(int i=0;i<N;i++){
int x=GetRequest();
if(on[x])continue;
int val=0;
for(int j=0;j<=mx;j++,A++)val+=((1<<j)*(*A));
PutBack(val);
on[val]=0;
have[pos[val]]=x;
pos[x]=pos[val];
on[x]=1;
}
}
}
Compilation message
advisor.cpp:33:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
33 | #pragma GCC optimize ("03,unroll-lopps")
| ^
advisor.cpp:35:47: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
35 | void ComputeAdvice(int *C, int N, int K, int M){
| ^
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:36:21: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
36 | auto get=[&](int x){for(int i=20;i>=0;i--)if(x&(1<<i))return i;};
| ^
advisor.cpp: In lambda function:
advisor.cpp:36:66: warning: control reaches end of non-void function [-Wreturn-type]
36 | auto get=[&](int x){for(int i=20;i>=0;i--)if(x&(1<<i))return i;};
| ^
assistant.cpp:33:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
33 | #pragma GCC optimize ("03,unroll-lopps")
| ^
assistant.cpp:35:50: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
35 | void Assist(unsigned char *A, int N, int K, int R){
| ^
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:37:22: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
37 | auto get2=[&](int x){for(int i=20;i>=0;i--)if(x&(1<<i))return i;};
| ^
assistant.cpp: In lambda function:
assistant.cpp:37:67: warning: control reaches end of non-void function [-Wreturn-type]
37 | auto get2=[&](int x){for(int i=20;i>=0;i--)if(x&(1<<i))return i;};
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
796 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
1856 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
148 ms |
10236 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
812 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
179 ms |
13056 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
165 ms |
12840 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
162 ms |
12580 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
165 ms |
12220 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
169 ms |
12188 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
169 ms |
12188 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
159 ms |
12228 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
160 ms |
12448 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
163 ms |
12156 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
175 ms |
13272 KB |
Output isn't correct - not an optimal way |