Submission #231484

# Submission time Handle Problem Language Result Execution time Memory
231484 2020-05-13T18:36:07 Z MKopchev Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
0 / 100
7000 ms 5288 KB
#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++)
    {
        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)
{
    pointer=0;
    for(int i=1;pointer<=n;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 Execution timed out 7069 ms 5288 KB Time limit exceeded
2 Execution timed out 7099 ms 5112 KB Time limit exceeded