#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+1;
}
#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) {
--h;
iniciar();
if(vals[q]&(1<<h)){
return 1;
}else return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4242 ms |
24104 KB |
Output is correct - maxh = 12 |
2 |
Correct |
3549 ms |
24024 KB |
Output is correct - maxh = 12 |