#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;
vector<vector<bool>> subs;
void genSub(){
vector<bool> sub;
for(int i = 0; i < maxh/2; i++){
sub.pb(0);
}
for(int i = maxh/2; i < maxh; i++){
sub.pb(1);
}
do{
subs.pb(sub);
}
while(next_permutation(all(sub)));
}
bool calculated = false;
void precalc(){
if(calculated) return;
calculated = true;
genSub();
}
int encode (int n, int x, int y) {
precalc();
x--;
y--;
for(int i = 0; i < maxh; i++){
if(subs[x][i] && !subs[y][i]){
return i+1;
}
}
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;
vector<vector<bool>> subs;
void genSub(){
vector<bool> sub;
for(int i = 0; i < maxh/2; i++){
sub.pb(0);
}
for(int i = maxh/2; i < maxh; i++){
sub.pb(1);
}
do{
subs.pb(sub);
}
while(next_permutation(all(sub)));
}
bool calculated = false;
void precalc(){
if(calculated) return;
calculated = true;
genSub();
}
int decode (int n, int q, int h) {
precalc();
q--;
if(subs[q][h-1]) return 1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5645 ms |
24812 KB |
Output is correct - maxh = 12 |
2 |
Correct |
4786 ms |
25008 KB |
Output is correct - maxh = 12 |