Submission #112502

# Submission time Handle Problem Language Result Execution time Memory
112502 2019-05-20T10:40:06 Z KCSC Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
0 / 100
7000 ms 10540 KB
#include <bits/stdc++.h>
using namespace std;

int codes[925];

void codeGenerator(void) {
	int val = 0;
	for (int mask = 0; mask < (1 << 12); ++mask) {
		if (__builtin_popcount(mask) == 6) {
			codes[++val] = mask; } } }

int encode(int N, int X, int Y) {
	codeGenerator();
	for (int i = 0; i < 12; ++i) {
		if (((codes[X] >> i) & 1) and !((codes[Y] >> i) & 1)) {
			return i + 1; } } }

int decode(int N, int Q, int H) {
	codeGenerator();
	if (codes[Q] & (1 << (H - 1))) {
		return 1; }
	return 0; }

#ifdef HOME
int main(void) {
	freopen("question.in", "r", stdin);
	freopen("question.out", "w", stdout);
	int T; cin >> T;
	while (T--) {
		int N, X, Y, Q; cin >> N >> X >> Y >> Q;
		cout << decode(N, Q, encode(N, X, Y)) << endl; }	
	return 0; }
#endif
#include <bits/stdc++.h>
using namespace std;

int codes[925];

void codeGenerator(int N) {
	int val = 0;
	for (int mask = 0; mask < (1 << 12) and val < N; ++mask) {
		if (__builtin_popcount(mask) == 6) {
			codes[++val] = mask; } } }

int encode(int N, int X, int Y) {
	codeGenerator(N);
	for (int i = 0; i < 12; ++i) {
		if (((codes[X] >> i) & 1) and !((codes[Y] >> i) & 1)) {
			return i + 1; } } }

int decode(int N, int Q, int H) {
	codeGenerator(N);
	if (codes[Q] & (1 << (H - 1))) {
		return 1; }
	return 0; }

#ifdef HOME
int main(void) {
	freopen("question.in", "r", stdin);
	freopen("question.out", "w", stdout);
	int T; cin >> T;
	while (T--) {
		int N, X, Y, Q; cin >> N >> X >> Y >> Q;
		cout << decode(N, Q, encode(N, X, Y)) << endl; }	
	return 0; }
#endif

Compilation message

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:16:22: warning: control reaches end of non-void function [-Wreturn-type]
    return i + 1; } } }
                      ^

decoder.cpp: In function 'int encode(int, int, int)':
decoder.cpp:16:22: warning: control reaches end of non-void function [-Wreturn-type]
    return i + 1; } } }
                      ^
# Verdict Execution time Memory Grader output
1 Execution timed out 7096 ms 10540 KB Time limit exceeded
2 Execution timed out 7073 ms 10276 KB Time limit exceeded