SHARE
TWEET

Untitled

a guest Nov 9th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <set>
  5. #include <map>
  6. #include <sstream>
  7. #include <queue>
  8. #include <algorithm>
  9. #include <cmath>
  10.  
  11. #define lol long long
  12.  
  13. using namespace std;
  14.  
  15. bool is_good(int a, int b, int c)
  16. {
  17.   return a * b >= c && a + b - 1 <= c;
  18. }
  19.  
  20. struct Coord
  21. {
  22.   int x, y, z;
  23.  
  24.   int get_coord(int i)
  25.   {
  26.     if (i == 0)
  27.       return x;
  28.     if (i == 1)
  29.       return z;
  30.     if (i == 2)
  31.       return y;
  32.   }
  33. };
  34.  
  35. int main()
  36. {
  37.   int d[3];
  38.   cin >> d[0] >> d[1] >> d[2];
  39.  
  40.   vector<int> v{0,1,2};
  41.   vector<int> good_perm;
  42.   do
  43.   {
  44.     if (d[v[0]] <= d[v[1]] && d[v[1]] <= d[v[2]])
  45.     {
  46.       good_perm = v;
  47.       break;
  48.     }
  49.   } while (next_permutation(v.begin(), v.end()));
  50.  
  51.  
  52.   sort(d, d + 3);
  53.  
  54.   int a = d[0];
  55.   int b = d[1];
  56.   int c = d[2];
  57.  
  58.   if (a * b < c)
  59.     return cout << -1, 0;
  60.  
  61.   vector<Coord> ans;
  62.   int cur = -99;
  63.   int A = a;
  64.   for (int i = 0; i < A-1; ++i)
  65.   {
  66.     if (!is_good(a, b, c))
  67.     {
  68.       ans.push_back({ cur, cur, cur });
  69.       cur++;
  70.       --a, --b, --c;
  71.     }
  72.     else
  73.     {
  74.       for (int i = 0; i < a; ++i)
  75.         ans.push_back({ cur + i, cur, cur });
  76.       for (int i = 1; i < b; ++i)
  77.         ans.push_back({ cur, cur + i, cur });
  78.       c -= a + b - 1;
  79.       for (int i = 0; i < a-1; ++i)
  80.       {
  81.         if (!c)
  82.           break;
  83.         for (int j = 0; j < b - 1; ++j)
  84.         {
  85.           if (!c)
  86.             break;
  87.  
  88.           ans.push_back({ cur + i + 1, cur + j + 1, cur });
  89.           --c;
  90.         }
  91.       }
  92.       a = b = c = 0;
  93.       break;
  94.     }
  95.   }
  96.  
  97.   if (a == 1 && b != c)
  98.     cout << "HUI2\n";
  99.  
  100.   if (a == 1)
  101.   {
  102.     for (int j = 0; j < b; ++j)
  103.       ans.push_back({ cur, cur + j, cur });
  104.     a = b = c = 0;
  105.   }
  106.  
  107.   if (a || b || c)
  108.     cout << "HUI\n";
  109.  
  110.   cout << ans.size() << "\n";
  111.   for (int i = 0; i < ans.size(); ++i)
  112.   {
  113.     for (int j = 0; j < 3; ++j)
  114.       for (int k = 0; k < good_perm.size(); ++k)
  115.         if (good_perm[k] == j)
  116.           cout << ans[i].get_coord(k) << " ";
  117.     cout << "\n";
  118.   }
  119. }
  120. /*
  121. 1
  122. 7 16
  123. 1 2
  124. 2 1
  125. 1 3 3 1
  126. 2 4 4 2
  127. 3 4 4 3
  128. 4 5 5 7 7 6 6 4
  129. 6 7
  130. 4 6
  131. 7 5
  132. 5 4
  133.  
  134.  
  135.  
  136. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top