Advertisement
Korotkodul

1C

Sep 27th, 2023 (edited)
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using std::cin;
  6. using std::cout;
  7. using std::max;
  8. using std::min;
  9. using std::string;
  10. using std::vector;
  11.  
  12. int main() {
  13.   std::ios::sync_with_stdio(false);
  14.   std::cin.tie(0);
  15.   std::cout.tie(0);
  16.   int nn;
  17.   int mm;
  18.   int ll;
  19.   cin >> nn >> mm >> ll;
  20.   vector<vector<int> > aa(nn, vector<int>(ll));
  21.   vector<vector<int> > bb(mm, vector<int>(ll));
  22.   for (int ii = 0; ii < nn; ++ii) {
  23.     for (int jj = 0; jj < ll; ++jj) {
  24.       cin >> aa[ii][jj];
  25.     }
  26.   }
  27.   for (int ii = 0; ii < mm; ++ii) {
  28.     for (int jj = 0; jj < ll; ++jj) {
  29.       cin >> bb[ii][jj];
  30.     }
  31.   }
  32.  
  33.   int qq;
  34.   cin >> qq;
  35.   for (int tt = 0; tt < qq; ++tt) {
  36.     int ii;
  37.     int jj;
  38.     cin >> ii >> jj;
  39.     ii--;
  40.     jj--;
  41.     int res = max(aa[ii][0], bb[jj][0]);
  42.     int ans = 0;
  43.  
  44.     for (int kk = 0; kk < ll; ++kk) {
  45.       if (res > max(aa[ii][kk], bb[jj][kk])) {
  46.         res = max(aa[ii][kk], bb[jj][kk]);
  47.         ans = kk;
  48.       }
  49.     }
  50.     cout << ans + 1 << "\n";
  51.   }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement