Advertisement
Guest User

Untitled

a guest
Nov 9th, 2019
134
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.  
  3. using namespace std;
  4.  
  5. const int N = 2e5+5, INF = 1e9;
  6.  
  7.  
  8. int main(){
  9.     ios_base::sync_with_stdio(0);
  10.     cin.tie(0); cout.tie(0);
  11.     int n, m, N, M, ans = 0;
  12.     cin >> n >> m;
  13.     vector<vector<int>> a(n,vector<int>(m));
  14.     for(int i = 0; i < n ;++i)
  15.         for(int j = 0; j < m; ++j)
  16.             cin >> a[i][j];
  17.     cin >> N >> M;
  18.     vector<vector<int>> b(N,vector<int>(M)), tm;
  19.     set<vector<vector<int>>> s;
  20.     for(int i = 0; i < N; ++i)
  21.         for(int j = 0; j < M; ++j)
  22.             cin >> b[i][j];
  23.     for(int i = 0; i < n-N+1; ++i){
  24.         for(int j = 0; j < m-M+1; ++j){
  25.             bool okf = true;
  26.             tm = a;
  27.             for(int I = i; I < i+N; ++I){
  28.                 for(int J = j; J < j+M; ++J){
  29.                     if(a[I][J]==0 && b[I-i][J-j]==1) okf = false;
  30.                     if(a[I][J]==1 && b[I-i][J-j]==0) tm[I][J] = 0;;
  31.                 }
  32.             }
  33.             for(int I = 0; I < n; ++I){
  34.                 for(int J = 0; J < m; ++J){
  35.                     if(!(I>=i&&I<i+N && J>=j&&J<j+M)) tm[I][J] = 0;
  36.                 }
  37.             }
  38.             ans+=okf&&!s.count(tm);
  39.             if(okf) s.insert(tm);
  40.         }
  41.     }
  42.     cout << ans;
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement