arujbansal

CF 46 P3

Sep 4th, 2021
1,366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 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, M;
  20.     cin >> N >> M;
  21.  
  22.     int A[N][M];
  23.     for (int i = 0; i < N; i++)
  24.         for (int j = 0; j < M; j++)
  25.             cin >> A[i][j];
  26.  
  27.     vector<vector<int>> ans;
  28.  
  29.     for (int j = M  - 1; j >= 0; j--) {
  30.         ans.emplace_back();
  31.  
  32.         for (int i = 0; i < N; i++)
  33.             ans.back().push_back(A[i][j]);
  34.     }
  35.  
  36.     for (int i = 0; i < N; i++) {
  37.         for (int j = 0; j < M; j++)
  38.             cout << A[i][j] << " ";
  39.  
  40.         cout << "\n";
  41.     }
  42.  
  43.     for (int j = 0; j < M * M; j++)
  44.         cout << "-";
  45.  
  46.     cout << "\n";
  47.  
  48.     for (const auto &row : ans) {
  49.         for (const auto &x : row) {
  50.             cout << x << " ";
  51.         }
  52.  
  53.         cout << "\n";
  54.     }
  55. }
  56.  
  57. signed main() {
  58.     ios_base::sync_with_stdio(false);
  59.     cin.tie(nullptr);
  60.  
  61.     int TC = 1;
  62.     // cin >> TC;
  63.     while (TC--) solve();
  64. }
Advertisement
Add Comment
Please, Sign In to add comment