#include <bits/stdc++.h>
using namespace std;
int codes[1000],pointer=0;
int encode(int n,int x,int y)
{
pointer=0;
for(int i=1;pointer<=n;i++)
{
int mem_i=i,bits=0;
while(mem_i)
{
bits=bits+mem_i%2;
mem_i=mem_i/2;
}
if(bits==6)
{
pointer++;
codes[pointer]=i;
}
}
x=codes[x];
y=codes[y];
for(int h=0;true;h++)
if((x&(1<<h))>0&&(y&(1<<h))==0)return h+1;
return -1;
}
/*
int main()
{
cout<<encode(920,5,6)<<endl;
cout<<encode(920,1,2)<<endl;
cout<<encode(920,4,5)<<endl;
cout<<encode(920,1,2)<<endl;
cout<<encode(920,3,5)<<endl;
cout<<encode(920,4,5)<<endl;
cout<<encode(920,5,2)<<endl;
return 0;
}
*/
#include <bits/stdc++.h>
using namespace std;
int codes[1000],pointer=0;
int decode(int n,int q,int h)
{
pointer=0;
for(int i=1;pointer<=n;i++)
{
int mem_i=i,bits=0;
while(mem_i)
{
bits=bits+mem_i%2;
mem_i=mem_i/2;
}
if(bits==6)
{
pointer++;
codes[pointer]=i;
}
}
q=codes[q];
if((q&(1<<(h-1))))return 1;
return 0;
}
/*
int main()
{
cout<<decode(920,5,2)<<endl;
cout<<decode(920,1,6)<<endl;
cout<<decode(920,4,3)<<endl;
cout<<decode(920,2,6)<<endl;
cout<<decode(920,3,3)<<endl;
cout<<decode(920,5,3)<<endl;
cout<<decode(920,2,6)<<endl;
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
7032 ms |
3240 KB |
Time limit exceeded |
2 |
Execution timed out |
7052 ms |
2712 KB |
Time limit exceeded |