-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path19.cpp
More file actions
59 lines (53 loc) · 1.25 KB
/
Copy path19.cpp
File metadata and controls
59 lines (53 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
namespace Hyx {
#ifndef ONLINE_JUDGE
// #include "debug_template.hpp"
#else
#define debug(...)
#define debugArr(...)
#endif // ONLINE_JUDGE
int a[100];
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "rb", stdin);
// freopen("output.txt", "wb", stdout);
#endif // ONLINE_JUDGE
int n = 8;
for (int i = 1; i <= 2 * n; i++) {
a[i] = i;
}
mt19937 rng(time(0));
shuffle(a + 1, a + 2 * n + 1, rng);
auto check = [&n](int a[]) -> bool {
for (int i = 1; i <= n; i++) {
if (a[i] - a[i + n] != i) {
return false;
}
}
return true;
};
int cnt = 0;
do {
if (check(a)) {
cout << "a:";
for (int i = 1; i <= n; i++) {
cout << a[i] << " ";
}
cout << "\nb:";
for (int i = n + 1; i <= 2 * n; i++) {
cout << a[i] << " ";
}
cout << "\n---------\n";
cnt++;
}
} while (next_permutation(a + 1, a + 2 * n + 1));
cout << "cnt = " << cnt;
return 0;
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
return Hyx::main();
}