#include <bits/stdc++.h>
int popcount(int x){
int res=0;
while(x){
res+=x&1;
x/=2;
}
return res;
}
int vals[1000];
int diferenca(int x,int y){
for(int i=0;i!=20;++i){
int a=x&(1<<i);
int b=y&(1<<i);
if(a&&!b)return i;
}
assert(0);
}
bool foi=false;
void iniciar(void)
{
if(foi)return;
foi=true;
int cur=1;
for(int i=0;i!=4096;++i){
int k = popcount(i);
if(k==6){
vals[cur]=i;
++cur;
}
}
}
int encode (int n, int x, int y) {
iniciar();
int a=vals[x],b=vals[y];
int place = diferenca(a,b);
return place;
}
#include <bits/stdc++.h>
int popcount(int x){
int res=0;
while(x){
res+=x&1;
x/=2;
}
return res;
}
int vals[1000];
int diferenca(int x,int y){
for(int i=0;i!=20;++i){
int a=x&(1<<i);
int b=y&(1<<i);
if(a&&!b)return i;
}
assert(0);
}
bool foi=false;
void iniciar(void)
{
if(foi)return;
foi=true;
int cur=1;
for(int i=0;i!=4096;++i){
int k = popcount(i);
if(k==6){
vals[cur]=i;
++cur;
}
}
}
int decode (int n, int q, int h) {
iniciar();
if(vals[q]&(1<<h)){
return 1;
}else return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
484 KB |
the encoded value must be greater than or equal to 1 |
2 |
Incorrect |
0 ms |
520 KB |
the encoded value must be greater than or equal to 1 |