DuongNhi99

MENU

Dec 10th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int a[1000][1000], b[1000][1000];
  5.  
  6. int main() {
  7.     freopen("MENU.inp", "r", stdin);
  8.     freopen("MENU.out", "w", stdout);
  9.     ios_base::sync_with_stdio(false);
  10.     cin.tie(0); cout.tie(0);
  11.  
  12.     int n, m; cin >> n>> m;
  13.     for (int i = 1; i <= n; ++i)
  14.         for(int j = 1; j <= m; ++j)
  15.             cin >> a[i][j];
  16.  
  17.     int q; cin >> q;
  18.     for (int i = 1; i <= q; ++i)
  19.         for(int j = 1; j <= m; ++j)
  20.             cin >> b[i][j];
  21.  
  22.     for(int k = 1; k <= q; ++k){
  23.         int res = 0;
  24.         for (int i = 1; i <= n; ++i){
  25.             int no = 0;
  26.             for(int j = 1; j <= m; ++j){
  27.                 if (b[k][j] != -1 && b[k][j] != a[i][j]){
  28.                     no = 1;
  29.                 }
  30.             }
  31.             if (no == 0) res++;
  32.         }
  33.  
  34.         cout << res << '\n';
  35.     }
  36.     return 0;
  37. }
  38. /*
  39. 3 8
  40. 6 5 97 99 82 50 95 1
  41. 85 62 11 64 94 84 88 19
  42. 43 99 11 64 94 84 31 19
  43. 3
  44. -1 -1 11 64 94 84 -1 19
  45. -1 -1 -1 99 -1 -1 -1 1
  46. 95 -1 -1 -1 -1 80 -1 -1
  47. */
  48.  
Advertisement
Add Comment
Please, Sign In to add comment