#include "bits/stdc++.h"
using namespace std;
vector <int> v[1000];
void create() {
if(!v[1].empty()) return ;
int idx = 0;
for(int i = 0; i < (1 << 12); i++) {
if(__builtin_popcount(i) == 6) {
++idx;
for(int j = 0; j < 12; j++) {
if((i >> j) & 1) {
v[idx].push_back(j + 1);
}
}
}
}
}
int encode (int n, int x, int y) {
create();
set <int> s (v[y].begin(), v[y].end());
for(auto i : v[x]) {
if(s.find(i) == s.end()) return i;
}
return -1;
}
#include "bits/stdc++.h"
using namespace std;
vector <int> g[1000];
void generate() {
if(!g[1].empty()) return ;
int idx = 0;
for(int i = 0; i < (1 << 12); i++) {
if(__builtin_popcount(i) == 6) {
++idx;
for(int j = 0; j < 12; j++) {
if((i >> j) & 1) {
g[idx].push_back(j + 1);
}
}
}
}
}
int decode (int n, int q, int h) {
generate();
for(auto i : g[q]) {
if(i == h) return 1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2635 ms |
27532 KB |
Output is correct - maxh = 12 |
2 |
Correct |
2669 ms |
27532 KB |
Output is correct - maxh = 12 |