Submission #1207142

#TimeUsernameProblemLanguageResultExecution timeMemory
1207142lovrotQuestion (Grader is different from the original contest) (CEOI14_question_grader)C++20
0 / 100
0 ms320 KiB
#include <cstdio>

using namespace std;

namespace A { 
	const int N = 1e3;
	const int LOG = 12;

	int mask[N];

	int bitperm(int x, int k) { 
		int ret = x + (x & -x);
		return ret + (1 << (k - __builtin_popcount(ret))) - 1;
	}

	void give_mask() { 
		int x = (1 << (LOG / 2)) - 1;
		for(int i = 1; i <= 924; ++i) { 
			mask[i] = x;
			if(i == 924) return;
			x = bitperm(x, LOG / 2);
		}
	}
}

int encode(int n, int x, int y) { 
	using namespace A;

	give_mask();

	for(int i = 0; i < LOG; ++i) { 
		if(!(x & (1 << i)) && (y & (1 << i))) { 
			return i + 1;
		}
	}
	return 0;
}
#include <cstdio>

using namespace std;

namespace B { 
	const int N = 1e3;
	const int LOG = 12;

	int mask[N];

	int bitperm(int x, int k) { 
		int ret = x + (x & -x);
		return ret + (1 << (k - __builtin_popcount(ret))) - 1;
	}

	void give_mask() { 
		int x = (1 << (LOG / 2)) - 1;
		for(int i = 1; i <= 924; ++i) { 
			mask[i] = x;
			if(i == 924) return;
			x = bitperm(x, LOG / 2);
		}
	}
}

int decode(int n, int x, int h) { 
	using namespace B;

	give_mask();

	return (bool) (x & (1 << (h - 1)));
}
#Verdict Execution timeMemoryGrader output
Fetching results...