# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
100971 | square1001 | 질문 (CEOI14_question_grader) | C++14 | 1885 ms | 78888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
static bool first_encode = true;
int size_encode = 0;
vector<vector<int> > perm_encode;
int encode(int n, int x, int y) {
if (first_encode) {
function<int(int, int)> comb = [&](int n, int m) {
int ans = 1;
for (int i = 1; i <= m; ++i) {
ans = (long long)(ans) * (n - m + i) / i;
}
return ans;
};
while (comb(size_encode * 2, size_encode) <= n) ++size_encode;
string perm = string(size_encode, 'o') + string(size_encode, 'x');
do {
vector<int> v;
for (int i = 0; i < size_encode * 2; ++i) {
if (perm[i] == 'o') v.push_back(i);
}
perm_encode.push_back(v);
} while (next_permutation(perm.begin(), perm.end()));
first_encode = false;
}
vector<int> a = perm_encode[x];
vector<int> b = perm_encode[y];
for (int i : a) {
if (find(b.begin(), b.end(), i) == b.end()) {
return i + 1;
}
}
return -1;
}
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
static bool first_decode = true;
vector<vector<int> > perm_decode;
int size_decode = 0;
int decode(int n, int q, int h) {
if (first_decode) {
function<int(int, int)> comb = [&](int n, int m) {
int ans = 1;
for (int i = 1; i <= m; ++i) {
ans = (long long)(ans) * (n - m + i) / i;
}
return ans;
};
while (comb(size_decode * 2, size_decode) <= n) ++size_decode;
string perm = string(size_decode, 'o') + string(size_decode, 'x');
do {
vector<int> v;
for (int i = 0; i < size_decode * 2; ++i) {
if (perm[i] == 'o') v.push_back(i);
}
perm_decode.push_back(v);
} while (next_permutation(perm.begin(), perm.end()));
first_decode = false;
}
vector<int> a = perm_decode[q];
if (find(a.begin(), a.end(), h - 1) != a.end()) return 1;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |