Submission #387851

#TimeUsernameProblemLanguageResultExecution timeMemory
387851Nima_NaderiQuestion (Grader is different from the original contest) (CEOI14_question_grader)C++14
100 / 100
3753 ms24436 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 1e4 + 10;
const ll LOG = 12;
ll Mask[MXN]; bool gen = 0;
void prep(ll n){
 	gen = 1; ll ts = 1;
  	for(int mask = 0; mask < (1LL << 12); mask ++){
        ll pc = __builtin_popcountll(mask);
		if(pc != 6) continue;
		Mask[ts ++] = mask;
		if(ts > n) break;
	}
}
int encode (int n, int x, int y) {
  	if(!gen) prep(n);
    int h = 0, xr = Mask[x] ^ Mask[y];
    for(int i = 0; i < LOG; i ++){
        if((xr >> i) & 1LL){
			if((Mask[x] >> i) & 1LL){
				h = i;
				h ++;
				return h;
			}
    	}
    }
	return -1;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 1e4 + 10;
const ll LOG = 12;
ll Mask[MXN]; bool gen = 0;
void prep(ll n){
 	gen = 1; ll ts = 1;
  	for(int mask = 0; mask < (1LL << 12); mask ++){
        ll pc = __builtin_popcountll(mask);
		if(pc != 6) continue;
		Mask[ts ++] = mask;
		if(ts > n) break;
	}
}
int decode (int n, int q, int h) {
  	if(!gen) prep(n);
	h --;
    q = Mask[q];
    return (((q >> h) & 1LL));
}
#Verdict Execution timeMemoryGrader output
Fetching results...