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>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 201010
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int T;
cin >> T;
vector<vector<int>> vs;
int i;
for (i = 0; i < (1 << 12); i++) {
int j;
vector<int> v;
for (j = 0; j < 12; j++) if (i >> j & 1) v.push_back(j + 1);
auto chk = [&]() {
for (auto x : v) {
for (auto y : v) {
int g = gcd(x, y);
if (!(i >> (g - 1) & 1)) return false;
}
}
return true;
};
reverse(v.begin(), v.end());
if (chk()) vs.push_back(v);
}
sort(vs.begin(), vs.end(), [&](vector<int> v1, vector<int> v2) {
int n, m;
n = v1.size();
m = v2.size();
int i;
for (i = 0; i < max(n, m); i++) {
if (n <= i) return true;
if (m <= i) return false;
if (v1[i] == v2[i]) continue;
return v1[i] < v2[i];
}
return false;
});
while (T--) {
int N;
cin >> N;
vector<int> ans = vs[N];
reverse(ans.begin(), ans.end());
cout << ans.size() << bb;
for (auto v : ans) cout << v << bb;
cout << ln;
}
}
# | 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... |