# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
543341 | eecs | Present (RMI21_present) | C++17 | 1826 ms | 4372 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int T, K, lim[1 << 19], mark[38], cnt[1 << 18];
bool ok1[1 << 19], ok2[1 << 18];
int main() {
for (int i = 0; i < 1 << 19; i++) {
ok1[i] = 1, lim[i] = (1 << 18) - 1;
for (int j = 0; j < 19 && ok1[i]; j++) if (i >> j & 1) {
for (int k = j + 1; k < 19; k++) if (i >> k & 1) {
ok1[i] &= i >> (__gcd(2 * j + 1, 2 * k + 1) / 2) & 1;
}
for (int k = 0; k < 18; k++) {
if (!(i >> (__gcd(2 * j + 1, 2 * k + 2) / 2) & 1)) lim[i] &= ~(1 << k);
}
}
}
for (int i = 0; i < 1 << 18; i++) {
ok2[i] = 1;
for (int j = 0; j < 18 && ok2[i]; j++) if (i >> j & 1) {
for (int k = j + 1; k < 18; k++) if (i >> k & 1) {
ok2[i] &= i >> (__gcd(2 * j + 2, 2 * k + 2) / 2 - 1) & 1;
}
}
}
auto calc = [&]() {
copy(ok2, ok2 + (1 << 18), cnt);
for (int i = 0; i < 1 << 18; i++) {
for (int j = 0; j < 18 && cnt[i]; j++) {
if (~mark[2 * j + 2] && mark[2 * j + 2] ^ (i >> j & 1)) cnt[i] = 0;
}
}
for (int i = 1; i < 1 << 18; i <<= 1) {
for (int j = 0; j < 1 << 18; j += i << 1) {
for (int k = 0; k < i; k++) cnt[i + j + k] += cnt[j + k];
}
}
long long s = 0;
for (int i = 0; i < 1 << 19; i++) if (ok1[i]) {
bool flag = 1;
for (int j = 0; j < 19 && flag; j++) {
if (~mark[2 * j + 1] && mark[2 * j + 1] ^ (i >> j & 1)) flag = 0;
}
if (flag) s += cnt[lim[i]];
}
return s;
};
scanf("%d", &T);
while (T--) {
scanf("%d", &K), K++;
memset(mark, -1, sizeof(mark));
vector<int> res;
for (int i = 37; i; i--) {
mark[i] = 0;
long long t = calc();
if (t < K) mark[i] = 1, K -= t, res.push_back(i);
}
printf("%d", res.size());
reverse(res.begin(), res.end());
for (int x : res) printf(" %d", x);
putchar('\n');
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |