Advertisement
arujbansal

Untitled

Nov 9th, 2021
1,065
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. void dbg_out() { cerr << endl; }
  6. template<typename Head, typename... Tail>
  7. void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
  8. #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
  9.  
  10. #define rng_init mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
  11. #define rng_seed(x) mt19937 rng(x)
  12. #define all(x) (x).begin(), (x).end()
  13. #define sz(x) (int) (x).size()
  14. // #define int long long
  15.  
  16. const int MXN = 1e5 + 5, INF = 1e9 + 5;
  17.  
  18. void solve() {
  19.     int N;
  20.     string S;
  21.  
  22.     cin >> N >> S;
  23.  
  24.     vector<char> A[N];
  25.  
  26.     int row = 0;
  27.     bool flag = true;
  28.  
  29.     for (int i = 0; i < sz(S); i++) {
  30.         A[row].push_back(S[i]);
  31.  
  32.         if (row == N - 1) flag = false;
  33.         else if (row == 0) flag = true;
  34.  
  35.         if (flag) row += 1;
  36.         else row -= 1;
  37.     }
  38.  
  39.     for (int i = 0; i < N; i++) {
  40.         for (int k = 0; k < sz(A[i]); k++) {
  41.             if (k == 0) {
  42.                 for (int j = 0; j < i; j++)
  43.                     cout << " ";
  44.                
  45.                 cout << A[i][k];
  46.  
  47.                 continue;
  48.             }
  49.  
  50.             if (i == 0 || i == N - 1) {
  51.                 for (int j = 0; j < max((N - i - 2) * 2 + 1, (i - 1) * 2 + 1); j++)
  52.                     cout << " ";
  53.                
  54.                 cout << A[i][k];
  55.  
  56.                 continue;
  57.             }
  58.  
  59.             if (k & 1) {
  60.                 for (int j = 0; j < (N - i - 2) * 2 + 1; j++)
  61.                     cout << " ";
  62.             } else {
  63.                 for (int j = 0; j < (i - 1) * 2 + 1; j++)
  64.                     cout << " ";
  65.             }
  66.  
  67.             cout << A[i][k];
  68.         }
  69.  
  70.         cout << "\n";
  71.     }
  72. }
  73.  
  74. signed main() {
  75.     ios_base::sync_with_stdio(false);
  76.     cin.tie(nullptr);
  77.  
  78.     int TC = 1;
  79.     // cin >> TC;
  80.     while (TC--) solve();
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement