SHARE
TWEET

Untitled

a guest May 19th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. int main() {
  6.     size_t n;
  7.     std::cin >> n;
  8.     size_t w_max = 0, h_max = 0;
  9.     std::vector<std::pair<size_t, size_t>> tr;
  10.     tr.reserve(n);
  11.     for (size_t i = 0; i < n; ++i) {
  12.         size_t part_n, part_m;
  13.         std::cin >> part_n >> part_m;
  14.         tr.push_back({part_n, part_m});
  15.         w_max += 2 * (part_m + part_n - 1) - 1;
  16.         h_max = std::max(h_max, (part_m + part_n - 1) * (part_m + part_n) / 2 - (part_m - 1) * (part_m) / 2);
  17.     }
  18.     w_max += n - 1;
  19.     size_t center_l, center_curr;
  20.     std::vector<std::vector<bool>> picture(h_max, std::vector<bool>(w_max, false));
  21.     std::vector<int> ban(h_max + 1);
  22.     size_t ind = 0;
  23.     center_curr = (tr[ind].first + tr[ind].second - 1) - 1;
  24.     size_t ii = 0;
  25.     for (size_t i = 0; i < tr[ind].first; ++i) {
  26.         for (size_t j = 0; j < tr[ind].second + i; ++j) {
  27.             for (size_t k = 0; k <= j; ++k) {
  28.                 picture[ii][center_curr + k] = true;
  29.                 picture[ii][center_curr - k] = true;
  30.             }
  31.             if (ii == 0) {
  32.                 ban[ii] = center_curr + 2;
  33.             } else if (j + 1 == tr[0].second + i) {
  34.                 ban[ii] = center_curr + j + 1;
  35.                 ban[ii + 1] = ban[ii];
  36.             } else if (j == 0) {
  37.  
  38.             } else {
  39.                 ban[ii] = center_curr + j + 2;
  40.             }
  41.             ++ii;
  42.         }
  43.     }
  44.     center_l = center_curr;
  45.     center_curr = center_l + 1;
  46.     ind = 1;
  47.     ii = 0;
  48.     for (size_t i = 0; i < tr[ind].first; ++i) {
  49.         for (size_t j = 0; j < tr[ind].second + i; ++j) {
  50.             if (center_curr <= ban[ii] + j) {
  51.                 center_curr =  j + ban[ii] + 1;
  52.             }
  53.             ++ii;
  54.         }
  55.     }
  56.     size_t w = w_max;
  57.     for (size_t t = 1; t < n; ++t) {
  58.         size_t ind = t;
  59.         size_t ii = 0;
  60.         for (size_t i = 0; i < tr[ind].first; ++i) {
  61.             for (size_t j = 0; j < tr[ind].second + i; ++j) {
  62.                 for (size_t k = 0; k <= j; ++k) {
  63.                     picture[ii][center_curr + k] = true;
  64.                     picture[ii][center_curr - k] = true;
  65.                 }
  66.                 if (ii == 0) {
  67.                     ban[ii] = center_curr + 2;
  68.                 } else if (j + 1 == tr[0].second + i) {
  69.                     ban[ii] = center_curr + j + 1;
  70.                     ban[ii + 1] = ban[ii];
  71.                 } else if (j == 0) {
  72.  
  73.                 } else {
  74.                     ban[ii] = center_curr + j + 2;
  75.                 }
  76.                 ++ii;
  77.             }
  78.         }
  79.         w = center_curr + tr[ind].first + tr[ind].second - 1;
  80.         if (t + 1 == n) {
  81.             break;
  82.         }
  83.         center_l = center_curr;
  84.         center_curr = center_l + 1;
  85.         ind = t + 1;
  86.         ii = 0;
  87.         for (size_t i = 0; i < tr[ind].first; ++i) {
  88.             for (size_t j = 0; j < tr[ind].second + i; ++j) {
  89.                 if (center_curr <= ban[ii] + j) {
  90.                     center_curr = j + ban[ii] + 1;
  91.                 }
  92.                 ++ii;
  93.             }
  94.         }
  95.     }
  96.     for (size_t i = 0; i < h_max; ++i) {
  97.         for (size_t j = 0; j < w; ++j) {
  98.             if (picture[i][j]) {
  99.                 std::cout << '#';
  100.             } else {
  101.                 std::cout << '.';
  102.             }
  103.         }
  104.         std::cout << "\n";
  105.     }
  106.     return 0;
  107. }
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