Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <set>
- #include <map>
- #include <sstream>
- #include <queue>
- #include <algorithm>
- #include <cmath>
- #define lol long long
- using namespace std;
- bool is_good(int a, int b, int c)
- {
- return a * b >= c && a + b - 1 <= c;
- }
- struct Coord
- {
- int x, y, z;
- int get_coord(int i)
- {
- if (i == 0)
- return x;
- if (i == 1)
- return z;
- if (i == 2)
- return y;
- }
- };
- int main()
- {
- int d[3];
- cin >> d[0] >> d[1] >> d[2];
- vector<int> v{0,1,2};
- vector<int> good_perm;
- do
- {
- if (d[v[0]] <= d[v[1]] && d[v[1]] <= d[v[2]])
- {
- good_perm = v;
- break;
- }
- } while (next_permutation(v.begin(), v.end()));
- sort(d, d + 3);
- int a = d[0];
- int b = d[1];
- int c = d[2];
- if (a * b < c)
- return cout << -1, 0;
- vector<Coord> ans;
- int cur = -99;
- int A = a;
- for (int i = 0; i < A-1; ++i)
- {
- if (!is_good(a, b, c))
- {
- ans.push_back({ cur, cur, cur });
- cur++;
- --a, --b, --c;
- }
- else
- {
- for (int i = 0; i < a; ++i)
- ans.push_back({ cur + i, cur, cur });
- for (int i = 1; i < b; ++i)
- ans.push_back({ cur, cur + i, cur });
- c -= a + b - 1;
- for (int i = 0; i < a-1; ++i)
- {
- if (!c)
- break;
- for (int j = 0; j < b - 1; ++j)
- {
- if (!c)
- break;
- ans.push_back({ cur + i + 1, cur + j + 1, cur });
- --c;
- }
- }
- a = b = c = 0;
- break;
- }
- }
- if (a == 1 && b != c)
- cout << "HUI2\n";
- if (a == 1)
- {
- for (int j = 0; j < b; ++j)
- ans.push_back({ cur, cur + j, cur });
- a = b = c = 0;
- }
- if (a || b || c)
- cout << "HUI\n";
- cout << ans.size() << "\n";
- for (int i = 0; i < ans.size(); ++i)
- {
- for (int j = 0; j < 3; ++j)
- for (int k = 0; k < good_perm.size(); ++k)
- if (good_perm[k] == j)
- cout << ans[i].get_coord(k) << " ";
- cout << "\n";
- }
- }
- /*
- 1
- 7 16
- 1 2
- 2 1
- 1 3 3 1
- 2 4 4 2
- 3 4 4 3
- 4 5 5 7 7 6 6 4
- 6 7
- 4 6
- 7 5
- 5 4
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement