Submission #113995

# Submission time Handle Problem Language Result Execution time Memory
113995 2019-05-29T13:18:15 Z dndhk Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
100 / 100
1260 ms 124544 KB
#include <bits/stdc++.h>

using namespace std;



vector<int> v;

int num = 0;
int cnt = 0;

void chk(int x){
	if(x==13){
		if(cnt==6){
			v.push_back(num);
		}
		return;
	}
	num = num * 2;
	chk(x+1);
	num++;
	cnt++;
	chk(x+1);
	num/=2;
	cnt--;
}


int encode (int n, int x, int y) {
	if(v.empty()){
		chk(1);
		sort(v.begin(), v.end());
	}
	x = v[x-1], y = v[y-1];
	int i = 1, two = 1;
	while(1){
		if((x&two)>0 && (y&two)==0){
			return i;
		}
		i++;
		two*=2;
	}
}
#include <bits/stdc++.h>


using namespace std;


vector<int> v2;

int num2 = 0;
int cnt2 = 0;

void chk2(int x){
	if(x==13){
		if(cnt2==6){
			v2.push_back(num2);
		}
		return;
	}
	num2 = num2 * 2;
	chk2(x+1);
	num2++;
	cnt2++;
	chk2(x+1);
	num2/=2;
	cnt2--;
}

int decode (int n, int q, int h) {
	if(v2.empty()){
		chk2(1);
		sort(v2.begin(), v2.end());
	}
	int t = v2[q-1];
	if((t & (1<<h-1))>0){
		return 1;
	}
	return 0;
}

Compilation message

decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:34:15: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
  if((t & (1<<h-1))>0){
              ~^~
# Verdict Execution time Memory Grader output
1 Correct 1260 ms 124528 KB Output is correct - maxh = 12
2 Correct 1255 ms 124544 KB Output is correct - maxh = 12