Submission #231485

# Submission time Handle Problem Language Result Execution time Memory
231485 2020-05-13T18:38:47 Z MKopchev Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
100 / 100
4459 ms 48392 KB
#include <bits/stdc++.h>
using namespace std;

int codes[1000],pointer=0;

int encode(int n,int x,int y)
{
    if(pointer==0)
    {

    for(int i=1;pointer<=920;i++)
    {
        if(__builtin_popcount(i)==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)
{
    if(pointer==0)
    {

    for(int i=1;pointer<=920;i++)
    {
        if(__builtin_popcount(i)==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;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 4459 ms 48392 KB Output is correct - maxh = 12
2 Correct 4382 ms 48216 KB Output is correct - maxh = 12