Submission #448664

# Submission time Handle Problem Language Result Execution time Memory
448664 2021-07-31T12:37:40 Z vanic Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
100 / 100
3655 ms 24064 KB
#include <vector>
#include <algorithm>

using namespace std;

int fact[13];

void precompute(){
	fact[0]=1;
	for(int i=1; i<13; i++){
		fact[i]=fact[i-1]*i;
	}
}

int povrh(int a, int b){
	return fact[a]/(fact[b]*fact[a-b]);
}

vector < int > radi(int x){
	vector < int > v;
	int ost=6;
	for(int i=1; i<=12; i++){
		if(!ost){
			break;
		}
		if(x>=povrh(12-i, ost-1)){
			x-=povrh(12-i, ost-1);
		}
		else{
			v.push_back(i);
			ost--;
		}
	}
	return v;
}

int encode (int n, int x, int y) {
	precompute();
	vector < int > s1, s2;
	s1=radi(x);
	s2=radi(y);
	while(!s2.empty()){
		if(find(s1.begin(), s1.end(), s2.back())!=s1.end()){
			s1.erase(find(s1.begin(), s1.end(), s2.back()));
		}
		s2.pop_back();
	}
	return s1.back();
}
#include <vector>
#include <algorithm>

using namespace std;

int fact[13];

void precompute(){
	fact[0]=1;
	for(int i=1; i<13; i++){
		fact[i]=fact[i-1]*i;
	}
}

int povrh(int a, int b){
	return fact[a]/(fact[b]*fact[a-b]);
}

vector < int > radi(int x){
	vector < int > v;
	int ost=6;
	for(int i=1; i<=12; i++){
		if(!ost){
			break;
		}
		if(x>=povrh(12-i, ost-1)){
			x-=povrh(12-i, ost-1);
		}
		else{
			v.push_back(i);
			ost--;
		}
	}
	return v;
}

int decode (int n, int q, int h) {
	precompute();
	vector < int > s1=radi(q);
	if(find(s1.begin(), s1.end(), h)!=s1.end()){
		return 1;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3644 ms 24032 KB Output is correct - maxh = 12
2 Correct 3655 ms 24064 KB Output is correct - maxh = 12