#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second
#define pii pair<int, int>
int mat1[1000][20];
int mat2[1000][1000];
bool flag = true;
int bit(int mask) {
int ret = 0;
for (int i = 0; i < 12; i++) {
if (mask & (1 << i)) ret++;
}
return ret;
}
int encode(int n, int x, int y) {
if (flag) {
flag = false;
int pos = 1;
for (int i = 1; i <= (1 << 12); i++) {
if (bit(i) != 6) continue;
for (int j = 0; j < 12; j++) {
if (i & (1 << j)) {
mat1[pos][j] = 1;
}
else {
mat1[pos][j] = 0;
}
}
pos++;
}
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < 1000; j++) {
if (i == j) continue;
for (int k = 0; k < 12; k++) {
if (!mat1[i][k] && mat1[j][k]) {
mat2[i][j] = k + 1;
}
}
}
}
}
return mat2[x][y];
}
//int main() {
// int a, b, c;
//
// cin >> a >> b >> c;
//
// cout << encoder(a, b, c) << "\n";
//
// return 0;
//}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second
#define pii pair<int, int>
int mat1[1000][20];
bool flag = true;
int bit(int mask) {
int ret = 0;
for (int i = 0; i < 12; i++) {
if (mask & (1 << i)) ret++;
}
return ret;
}
int decode(int n, int q, int h) {
if (flag) {
flag = false;
int pos = 1;
for (int i = 1; i <= (1 << 12); i++) {
if (bit(i) != 6) continue;
for (int j = 0; j < 12; j++) {
if (i & (1 << j)) {
mat1[pos][j] = 1;
}
else {
mat1[pos][j] = 0;
}
}
pos++;
}
}
return !mat1[q][h - 1];
}
//int main() {
// int a, b, c;
//
// cin >> a >> b >> c;
//
// cout << decoder(a, b, c) << "\n";
//
// return 0;
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4964 ms |
28368 KB |
Output is correct - maxh = 12 |
2 |
Correct |
4888 ms |
28268 KB |
Output is correct - maxh = 12 |