Submission #36523

# Submission time Handle Problem Language Result Execution time Memory
36523 2017-12-10T07:22:00 Z cheater2k Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
0 / 100
0 ms 27480 KB
#include <bits/stdc++.h>
using namespace std;

namespace A {
	int mp[960]; 
	bool called; // check whether function build() was called
	// map i (1 <= i <= 920) with a 12-bit integer j such that __builtin_popcount(j) = 6
	void build() {
		int cur = 0;
		for (int mask = 0; mask < (1 << 12); ++mask) {
			if (__builtin_popcount(mask) == 6) {
				mp[++cur] = mask;
			}
		}
	}
};

int encode (int n, int x, int y) {
	if (!A::called) A::called = true, A::build();
	int X = A::mp[x], Y = A::mp[y];
	for (int i = 0; i < 12; ++i) {
		int bitX = (X >> i & 1);
		int bitY = (Y >> i & 1);
		if (!bitX && bitY) {
			// the i-th bit of X is 0 while that of Y is 1
			return i;
		}
	}
}
#include <bits/stdc++.h>
using namespace std;

namespace B { // similar to namespace A
	int mp[960]; 
	bool called; // check whether function build() was called
	// map i (1 <= i <= 920) with a 12-bit integer j such that __builtin_popcount(j) = 6
	void build() {
		int cur = 0;
		for (int mask = 0; mask < (1 << 12); ++mask) {
			if (__builtin_popcount(mask) == 6) {
				mp[++cur] = mask;
			}
		}
	}
};

int decode (int n, int q, int h) { // X and Y is different at h-th bit
	if (!B::called) B::called = true, B::build();
	int Q = B::mp[q];
	int bitQ = Q >> h & 1;
	if (!bitQ) return true; else return false;
}

Compilation message

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 27480 KB Output isn't correct
2 Incorrect 0 ms 27480 KB Output isn't correct