Submission #448663

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

using namespace std;

int fact[10];

void precompute(){
	fact[0]=1;
	for(int i=1; i<10; 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[10];

void precompute(){
	fact[0]=1;
	for(int i=1; i<10; 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 Runtime error 2 ms 328 KB Execution killed with signal 8
2 Runtime error 2 ms 328 KB Execution killed with signal 8