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;
typedef int64_t ll;
const int N = 25, MX = 1e6 + 5;
vector<vector<int>> all;
vector<int> gud[N + 1];
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	all.push_back({});
	for (int i = 1; i <= N; i++) {
		gud[i].push_back(0);
	}
	for (int i = 1; i <= N && all.size() < MX; i++) {
		for (auto j : gud[i]) {
			if (all.size() >= MX) break;
			all.push_back(all[j]);
			all.back().push_back(i);
			bool frq[N + 1]{};
			for (auto x : all.back()) frq[x] = 1;
			for (int k = i + 1; k <= N; k++) {
				bool ok = 1;
				for (auto x : all.back()) {
					ok &= frq[gcd(x, k)];
				}
				if (ok) gud[k].push_back(all.size() - 1);
			}
		}
	}
	int t;
	cin >> t;
	while (t--) {
		int k;
		cin >> k;
		cout << all[k].size() << ' ';
		for (auto i : all[k]) {
			cout << i << ' ';
		}
		cout << '\n';
	}
	return 0;
}
| # | 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... |