Naxocist

Cromartie Mountain

Apr 25th, 2022 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. const int N = 100 + 3;
  6. char ar[N][N];
  7.  
  8.  
  9. int main() {
  10.     ios::sync_with_stdio(false); cin.tie(nullptr);
  11.    
  12.     int n; cin >> n;
  13.     int H = -1e9, L = -1e9;
  14.  
  15.     for(int i=0; i<100; ++i){
  16.         for(int j=0; j<100; ++j) ar[i][j] = '.';
  17.     }
  18.  
  19.     while(n--){
  20.         int s, h; cin >> s >> h;
  21.         s--; // index
  22.  
  23.         H = max(H, h-1);
  24.         L = max(L, s + h*2);
  25.         for(int j=0; j<h; ++j){
  26.             int st = s + j, ed = st + (h-j)*2 - 1;
  27.  
  28.             if(ar[j][st] == '.') ar[j][st] = '/';
  29.             else if(ar[j][st] == '\\') ar[j][st] = 'v';
  30.  
  31.             if(ar[j][ed] == '.') ar[j][ed] = '\\';
  32.             else if(ar[j][ed] == '/') ar[j][ed] = 'v';
  33.  
  34.             for(int k=st+1; k<ed; ++k) ar[j][k] = 'X';
  35.         }
  36.  
  37.     }
  38.  
  39.     for(int i=H; i>=0; --i){
  40.         for(int j=0; j<L; ++j){
  41.             cout << ar[i][j];
  42.         }
  43.         cout << '\n';
  44.     }
  45.  
  46. }
Add Comment
Please, Sign In to add comment