Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 2e5+5, INF = 1e9;
- int main(){
- ios_base::sync_with_stdio(0);
- cin.tie(0); cout.tie(0);
- int n, m, N, M, ans = 0;
- cin >> n >> m;
- vector<vector<int>> a(n,vector<int>(m));
- for(int i = 0; i < n ;++i)
- for(int j = 0; j < m; ++j)
- cin >> a[i][j];
- cin >> N >> M;
- vector<vector<int>> b(N,vector<int>(M)), tm;
- set<vector<vector<int>>> s;
- for(int i = 0; i < N; ++i)
- for(int j = 0; j < M; ++j)
- cin >> b[i][j];
- for(int i = 0; i < n-N+1; ++i){
- for(int j = 0; j < m-M+1; ++j){
- bool okf = true;
- tm = a;
- for(int I = i; I < i+N; ++I){
- for(int J = j; J < j+M; ++J){
- if(a[I][J]==0 && b[I-i][J-j]==1) okf = false;
- if(a[I][J]==1 && b[I-i][J-j]==0) tm[I][J] = 0;;
- }
- }
- for(int I = 0; I < n; ++I){
- for(int J = 0; J < m; ++J){
- if(!(I>=i&&I<i+N && J>=j&&J<j+M)) tm[I][J] = 0;
- }
- }
- ans+=okf&&!s.count(tm);
- if(okf) s.insert(tm);
- }
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement