SHARE
TWEET

Untitled

a guest May 24th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7.     srand(time(NULL));
  8.  
  9.     int n, m;
  10.     cin >> n >> m;
  11.  
  12.     vector < pair < int, int > > sp;
  13.     int f[n][m], v[n][m], h[n][m];
  14.     for (int i = 0; i < n; ++i){
  15.         for (int j = 0; j < m; ++j){
  16.             v[i][j] = h[i][j] = f[i][j] = rand() % 41 - 20;
  17.             v[i][j] = max(v[i][j], (i ? v[i - 1][j] : v[i][j]));
  18.             h[i][j] = min(h[i][j], (j ? h[i][j - 1] : h[i][j]));
  19.             cout << setw(4) << f[i][j] << " ";
  20.         }
  21.         cout << "\n";
  22.     }
  23.  
  24.     int _minv = v[n - 1][0];
  25.     for (int i = 1; i < m; ++i){
  26.         _minv = min(_minv, v[n - 1][i]);
  27.     }
  28.  
  29.     int _maxh = h[0][m - 1];
  30.     for (int i = 1; i < n; ++i){
  31.         _maxh = max(_maxh, h[i][m - 1]);
  32.     }
  33.  
  34.     cout << _minv << " " << _maxh << "\n";
  35.  
  36.     for (int i = 0; i < n; ++i){
  37.         for (int j = 0; j < m; ++j){
  38.             if (f[i][j] == v[n - 1][j] && f[i][j] == h[i][m - 1]){
  39.                 sp.push_back({ i, j });
  40.             }
  41.         }
  42.     }
  43.  
  44.     cout << sp.size() << "\n";
  45.     for (const auto &i : sp) {
  46.         cout << i.first << " " << i.second << "\n";
  47.     }
  48.  
  49. }
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