SHARE
TWEET

Untitled

a guest Jan 21st, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. typedef long long ll;
  4.  
  5. #define fr first
  6. #define sc second
  7. #define pii pair <int, int>
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12.     ios_base::sync_with_stdio(0);
  13.     cin.tie(0); cout.tie(0);
  14.     int n, m;
  15.     cin >> n >> m;
  16.     vector <vector <int>> ans(n, vector <int> (m));
  17.     for (int i = 0; i < n; i++) {
  18.         for (int j = 0; j < m; j++) cin >> ans[i][j];
  19.     }
  20.     vector <vector <int>> tmp(n, vector <int> (m));
  21.     for (int i = 0; i < n; i++) {
  22.         for (int j = 0; j < m; j++) cin >> tmp[i][j];
  23.     }
  24.     for (int i = n - 1; i >= 0; i--) {
  25.         for (int j = m - 1; j >= 0; j--) {
  26.             ans[i][j] = tmp[i][j];
  27.             if (tmp[i][j] == 1) break;
  28.         }
  29.     }
  30.     for (int i = 0; i < n; i++) {
  31.         for (int j = 0; j < m; j++) cout << ans[i][j] << " ";
  32.         cout << '\n';
  33.     }
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top