Submission #70422

# Submission time Handle Problem Language Result Execution time Memory
70422 2018-08-22T20:24:30 Z spencercompton Question (Grader is different from the original contest) (CEOI14_question_grader) C++17
100 / 100
1908 ms 170544 KB
#include <bits/stdc++.h>
using namespace std;
vector<string> ans;
string cur = "000000000000";
void gen(int now, int rem){
	if(rem<0){
		return;
	}
	int extra = 12-now;
	if(extra<rem){
		return;
	}
	if(now==12 && rem==0){
		ans.push_back(cur);
	}
	if(now<12){
		cur[now] = '0';
		gen(now+1,rem);
		cur[now] = '1';
		gen(now+1,rem-1);
	}
}

int encode (int n, int x, int y) {
    if(ans.size()==0){
	    gen(0,6);
    }
	x--;
	y--;
	for(int i = 0; i<12; i++){
		if(ans[x][i]=='1' && ans[y][i]=='0'){
			return i+1;
		}
	}
	assert(false);
	return 69;
}
#include <bits/stdc++.h>
using namespace std;
vector<string> ans1;
string cur1 = "000000000000";
void gen1(int now, int rem){
	if(rem<0){
		return;
	}
	int extra = 12-now;
	if(extra<rem){
		return;
	}
	if(now==12 && rem==0){
		ans1.push_back(cur1);
	}
	if(now<12){
		cur1[now] = '0';
		gen1(now+1,rem);
		cur1[now] = '1';
		gen1(now+1,rem-1);
	}
}

int decode (int n, int q, int h) {
    if(ans1.size()==0){
    	gen1(0,6);
    }
	if(ans1[q-1][h-1]=='1'){
		return 1;
	}
	else{
		return 0;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1844 ms 124400 KB Output is correct - maxh = 12
2 Correct 1908 ms 170544 KB Output is correct - maxh = 12