Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- int max_row, max_col;
- char mat[110][10000];
- struct elk {
- int a, b;
- };
- void pprint(int centr, int a, int b) {
- int cnt = 0;
- for (int i = 0; i < a; i++) {
- for (int j = 0; j < b+i; j++) {
- for (int k = centr-j; k<=centr+j; k++) {
- mat[cnt][k]='#';
- max_col = std::max(max_col, k);
- }
- max_row = std::max(max_row, cnt);
- cnt++;
- }
- }
- }
- int new_centr(int centr, int a, int b) {
- int nc = centr + 2;
- int cnt = 0;
- for (int i = 0; i < a; i++) {
- for (int j = 0; j < b+i; j++) {
- //std::cout << cnt+1 << " " << nc-j+1 << "\n";
- //std::cout << mat[cnt+1][nc-j+1] << "\n";
- 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] == '#'){
- nc++;
- }
- cnt++;
- }
- }
- return nc;
- }
- int main() {
- std::ios_base::sync_with_stdio(false);
- std::cin.tie(nullptr);
- std::cout.tie(nullptr);
- max_row = 0;
- max_col = 0;
- for (int i = 0; i < 100; i++) {
- for (int j = 0; j < 5000; j++) {
- mat[i][j] = '.';
- }
- }
- int n, a, b;
- std::cin >> n;
- std::vector<elk> elks;
- for (int i = 0; i < n; i++) {
- std::cin >> a >> b;
- elks.push_back({a, b});
- }
- int centr = elks[0].a+elks[0].b-2;
- pprint(centr, elks[0].a, elks[0].b);
- for (int i = 1; i < n; i++) {
- centr = new_centr(centr, elks[i].a, elks[i].b);
- pprint(centr, elks[i].a, elks[i].b);
- }
- for (int i = 0; i < max_row+1; i++) {
- for (int j = 0; j < max_col+1; j++) {
- std::cout << mat[i][j];
- }
- std::cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement