답안 #354407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
354407 2021-01-21T22:37:44 Z rqi 질문 (CEOI14_question_grader) C++14
0 / 100
463 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
 
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ins insert
 
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
 
const int maxh = 12;
static vector<vi> subs;
static vi sub;
 
static void genSub(int curnum = 1){
	if(sz(sub) == maxh/2){
		subs.pb(sub);
		// for(auto u: sub){
		// 	cout << u << " ";
		// }
		// cout << "\n";
		return;
	}
	for(int i = curnum; i <= maxh; i++){
		sub.pb(i);
		genSub(i+1);
		sub.pop_back();
	}
}

static vi getSub(int ind){
	// genSub();
	// return subs[ind];
	vi cursub(12, 0);
	for(int i = 0; i < maxh/2; i++){
		cursub[i] = 1;
	}
	for(int i = 0; i < ind; i++){
		next_permutation(all(cursub));
	}
	vi res;
	for(int i = 0; i < 12; i++){
		if(cursub[i] == 1) res.pb(i+1);
	}
	return res;
}
 
int encode (int n, int x, int y) {
	genSub();
	x--;
	y--;
	vector<bool> insub1(maxh+1, 0);
	vector<bool> insub2(maxh+1, 1);

	vi subx = getSub(x);
	vi suby = getSub(y);
	for(int k = 0; k < sz(subx); k++){
		insub1[subx[k]] = 1;
	}
 
	for(int k = 0; k < sz(suby); k++){
		insub2[suby[k]] = 0;
	}
	
	for(int h = 1; h <= maxh; h++){
		if(insub1[h] && insub2[h]){
			return h;
		}
	}
	return -1;
}
 
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
 
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ins insert
 
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
 
const int maxh = 12;
static vector<vi> subs;
static vi sub;
 
static void genSub(int curnum = 1){
	if(sz(sub) == maxh/2){
		subs.pb(sub);
		// for(auto u: sub){
		// 	cout << u << " ";
		// }
		// cout << "\n";
		return;
	}
	for(int i = curnum; i <= maxh; i++){
		sub.pb(i);
		genSub(i+1);
		sub.pop_back();
	}
}
 
 
int decode (int n, int q, int h) {
	genSub();
	q--;
	for(int i = 0; i < sz(subs[q]); i++){
		if(subs[q][i] == h) return 1;
	}
	return 0;
}
 
# 결과 실행 시간 메모리 Grader output
1 Runtime error 463 ms 262148 KB Execution killed with signal 9
2 Runtime error 459 ms 262144 KB Execution killed with signal 9