Advertisement
Guest User

Untitled

a guest
May 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. int max_row, max_col;
  3. char mat[110][10000];
  4.  
  5. struct elk {
  6. int a, b;
  7. };
  8.  
  9. void pprint(int centr, int a, int b) {
  10. int cnt = 0;
  11. for (int i = 0; i < a; i++) {
  12. for (int j = 0; j < b+i; j++) {
  13. for (int k = centr-j; k<=centr+j; k++) {
  14. mat[cnt][k]='#';
  15. max_col = std::max(max_col, k);
  16. }
  17. max_row = std::max(max_row, cnt);
  18. cnt++;
  19. }
  20. }
  21. }
  22.  
  23. int new_centr(int centr, int a, int b) {
  24. int nc = centr + 2;
  25. int cnt = 0;
  26. for (int i = 0; i < a; i++) {
  27. for (int j = 0; j < b+i; j++) {
  28. //std::cout << cnt+1 << " " << nc-j+1 << "\n";
  29. //std::cout << mat[cnt+1][nc-j+1] << "\n";
  30. while(nc-j < 0 || mat[cnt][nc-j] == '#' || mat[cnt][nc-j-1] == '#' || (cnt > 0 && mat[cnt-1][nc-j] == '#') || (cnt > 0 && mat[cnt-1][nc-j-1] == '#') || mat[cnt+1][nc-j-1] == '#' || mat[cnt+1][nc-j] == '#'){
  31. nc++;
  32. }
  33. cnt++;
  34. }
  35. }
  36. return nc;
  37. }
  38.  
  39. int main() {
  40. std::ios_base::sync_with_stdio(false);
  41. std::cin.tie(nullptr);
  42. std::cout.tie(nullptr);
  43. max_row = 0;
  44. max_col = 0;
  45. for (int i = 0; i < 100; i++) {
  46. for (int j = 0; j < 5000; j++) {
  47. mat[i][j] = '.';
  48. }
  49. }
  50. int n, a, b;
  51. std::cin >> n;
  52. std::vector<elk> elks;
  53. for (int i = 0; i < n; i++) {
  54. std::cin >> a >> b;
  55. elks.push_back({a, b});
  56. }
  57. int centr = elks[0].a+elks[0].b-2;
  58. pprint(centr, elks[0].a, elks[0].b);
  59. for (int i = 1; i < n; i++) {
  60. centr = new_centr(centr, elks[i].a, elks[i].b);
  61. pprint(centr, elks[i].a, elks[i].b);
  62. }
  63. for (int i = 0; i < max_row+1; i++) {
  64. for (int j = 0; j < max_col+1; j++) {
  65. std::cout << mat[i][j];
  66. }
  67. std::cout << "\n";
  68. }
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement