Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iostream>
- #include <vector>
- using std::cin;
- using std::cout;
- using std::max;
- using std::min;
- using std::string;
- using std::vector;
- int main() {
- std::ios::sync_with_stdio(false);
- std::cin.tie(0);
- std::cout.tie(0);
- int nn;
- int mm;
- int ll;
- cin >> nn >> mm >> ll;
- vector<vector<int> > aa(nn, vector<int>(ll));
- vector<vector<int> > bb(mm, vector<int>(ll));
- for (int ii = 0; ii < nn; ++ii) {
- for (int jj = 0; jj < ll; ++jj) {
- cin >> aa[ii][jj];
- }
- }
- for (int ii = 0; ii < mm; ++ii) {
- for (int jj = 0; jj < ll; ++jj) {
- cin >> bb[ii][jj];
- }
- }
- int qq;
- cin >> qq;
- for (int tt = 0; tt < qq; ++tt) {
- int ii;
- int jj;
- cin >> ii >> jj;
- ii--;
- jj--;
- int res = max(aa[ii][0], bb[jj][0]);
- int ans = 0;
- for (int kk = 0; kk < ll; ++kk) {
- if (res > max(aa[ii][kk], bb[jj][kk])) {
- res = max(aa[ii][kk], bb[jj][kk]);
- ans = kk;
- }
- }
- cout << ans + 1 << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement