#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
#define pb push_back
const int N = 1e3+11;
int a[N];
vector <int> v[N];
int brr = 0;
int b[15];
void prek (int pos) {
if (pos == 12) {
int br = 0;
for (int i=0;i<12;i++) br+=a[i];
if (br != 6) return;
for (int i=0;i<12;i++) {
if (a[i]) v[brr].pb(i);
}
brr++;
return;
}
a[pos] = 1;
prek (pos+1);
a[pos] = 0;
prek (pos+1);
}
int encode (int n, int x, int y) {
if (v[0].size() == 0) prek(0);
memset (b, 0, sizeof b);
for (int i=0;i<6;i++) {
b[v[x][i]]++;
b[v[y][i]]--;
}
for (int i=0;i<12;i++) {
if (b[i] == 1) return i+1;
}
}
/*
int main() {
int n, x, y;
cin >> n >> x >> y;
cout << encode (n, x, y);
}
*/
#include <iostream>
#include <vector>
using namespace std;
#define pb push_back
const int N = 1e3+11;
int a[N];
vector <int> v[N];
int brr = 0;
int b[N];
void prek (int pos) {
if (pos == 12) {
int br = 0;
for (int i=0;i<12;i++) br+=a[i];
if (br != 6) return;
for (int i=0;i<12;i++) {
if (a[i]) v[brr].pb(i);
}
brr++;
return;
}
a[pos] = 1;
prek (pos+1);
a[pos] = 0;
prek (pos+1);
}
int decode (int n, int q, int h) {
if (v[0].size() == 0) prek(0);
h--;
for (int i=0;i<6;i++) {
if (v[q][i] == h) return 1;
}
return 0;
}
/*
int main() {
int n, q, h;
cin >> n >> q >> h;
cout << decode(n, q, h);
}
*/
Compilation message
encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1701 ms |
80480 KB |
Output is correct - maxh = 12 |
2 |
Correct |
1686 ms |
80616 KB |
Output is correct - maxh = 12 |