#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 |
1 |
Correct |
3 ms |
320 KB |
Output is correct |
2 |
Correct |
3 ms |
320 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
316 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
320 KB |
Output is correct |
2 |
Correct |
3 ms |
320 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
316 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Runtime error |
4 ms |
596 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
320 KB |
Output is correct |
2 |
Correct |
3 ms |
320 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
316 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Runtime error |
4 ms |
596 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
320 KB |
Output is correct |
2 |
Correct |
3 ms |
320 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
316 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Runtime error |
4 ms |
596 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
320 KB |
Output is correct |
2 |
Correct |
3 ms |
320 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
316 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Runtime error |
4 ms |
596 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |