Submission #24558

# Submission time Handle Problem Language Result Execution time Memory
24558 2017-06-10T12:22:32 Z Bruteforceman Question (Grader is different from the original contest) (CEOI14_question_grader) C++11
100 / 100
2669 ms 27532 KB
#include "bits/stdc++.h"
using namespace std;

vector <int> v[1000];
void create() {
	if(!v[1].empty()) return ;
	int idx = 0;
	for(int i = 0; i < (1 << 12); i++) {
		if(__builtin_popcount(i) == 6) {
			++idx;
			for(int j = 0; j < 12; j++) {
				if((i >> j) & 1) {
					v[idx].push_back(j + 1);
				}
			}
		}
	}
}

int encode (int n, int x, int y) {
	create();
	set <int> s (v[y].begin(), v[y].end());
	for(auto i : v[x]) {
		if(s.find(i) == s.end()) return i;
	}
	return -1;
}
#include "bits/stdc++.h"
using namespace std;

vector <int> g[1000];
void generate() {
	if(!g[1].empty()) return ;
	int idx = 0;
	for(int i = 0; i < (1 << 12); i++) {
		if(__builtin_popcount(i) == 6) {
			++idx;
			for(int j = 0; j < 12; j++) {
				if((i >> j) & 1) {
					g[idx].push_back(j + 1);
				}
			}
		}
	}
}

int decode (int n, int q, int h) {
	generate();
	for(auto i : g[q]) {
		if(i == h) return 1;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2635 ms 27532 KB Output is correct - maxh = 12
2 Correct 2669 ms 27532 KB Output is correct - maxh = 12