aboutsummaryrefslogtreecommitdiff
path: root/01_introductory_problems/two_sets_1092.cpp
diff options
context:
space:
mode:
Diffstat (limited to '01_introductory_problems/two_sets_1092.cpp')
-rw-r--r--01_introductory_problems/two_sets_1092.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/01_introductory_problems/two_sets_1092.cpp b/01_introductory_problems/two_sets_1092.cpp
new file mode 100644
index 0000000..4314654
--- /dev/null
+++ b/01_introductory_problems/two_sets_1092.cpp
@@ -0,0 +1,53 @@
1#include <iostream>
2#include <vector>
3
4void printarr(const std::vector<int>& a) {
5 std::cout << a.size() << std::endl;
6 for (auto x : a)
7 std::cout << x << " ";
8 std::cout << std::endl;
9}
10
11int main() {
12 int n;
13 std::cin >> n;
14
15 switch (n % 4) {
16 case 1:
17 case 2:
18 std::cout << "NO\n";
19 break;
20 case 0:
21 std::cout << "YES\n";
22 {
23 std::vector<int> a(n/2), b(n/2);
24 for (int i = 0; i < n/4; i++) {
25 a[2*i] = 4*i+1;
26 a[2*i+1] = 4*i+4;
27 b[2*i] = 4*i+2;
28 b[2*i+1] = 4*i+3;
29 }
30 printarr(a);
31 printarr(b);
32 }
33 break;
34 case 3:
35 std::cout << "YES\n";
36 if (n == 3) {
37 std::cout << "2\n1 2\n1\n3\n";
38 } else {
39 std::vector<int> a(n/2+1), b(n/2);
40 a[0] = 1; a[1] = 2; a[2] = 4; a[3] = 7;
41 b[0] = 3; b[1] = 5; b[2] = 6;
42 for (int i = 1; i < n/4; i++) {
43 a[2*i+2] = 4*i+4;
44 a[2*i+3] = 4*i+7;
45 b[2*i+1] = 4*i+5;
46 b[2*i+2] = 4*i+6;
47 }
48 printarr(a);
49 printarr(b);
50 }
51 break;
52 }
53}

Generated with cgit - Back to sebastiano.tronto.net