/// "dar aparent merge sa faci orice pe pile"
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 950;
const int BMAX = 12;
const int MSK = (1 << BMAX) - 1;
vector<int> v;
bool isInit = false;
void init()
{
isInit = true;
for(int msk = 0; msk < (1 << BMAX); msk++)
if( __builtin_popcount(msk) == 6 )
v.push_back(msk);
}
int encode(int N, int x, int y)
{
if(!isInit) init();
int X = v[x - 1], Y = v[y - 1] ^ MSK;
int H = X & Y;
for(int i = 0; i < BMAX; i++)
if( (H >> i) & 1 )
return (i + 1);
return -1;
}
/// atunci nu cred ca am eu suficiente pile la tine :(
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 950;
const int BMAX = 12;
const int MSK = (1 << BMAX) - 1;
vector<int> v;
bool isInit = false;
void init()
{
isInit = true;
for(int msk = 0; msk < (1 << BMAX); msk++)
if( __builtin_popcount(msk) == 6 )
v.push_back(msk);
}
int decode(int N, int q, int h)
{
if(!isInit) init();
int b = h - 1;
int Q = v[q - 1];
if( (Q >> b) & 1 ) return 1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1561 ms |
124688 KB |
Output is correct - maxh = 12 |
2 |
Correct |
1546 ms |
124912 KB |
Output is correct - maxh = 12 |