-
Notifications
You must be signed in to change notification settings - Fork 33
/
imageoverlap.cpp
40 lines (38 loc) · 949 Bytes
/
imageoverlap.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream.h>
#include<bits/stdc++.h>
int largestOverlap(vector<vector<int>>& img1, vector<vector<int>>& img2) {
int n=img1.size();
vector<pair<int,int>>vec_a;
vector<pair<int,int>>vec_b;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(img1[i][j]==1){
vec_a.push_back({i,j});
}
if(img2[i][j]==1){
vec_b.push_back({i,j});
}
}
}
int ans=0;
map<pair<int,int>,int>mp;
for(auto [i1,j1]:vec_a){
for(auto [i2,j2]:vec_b){
mp[{i1-i2,j1-j2}]++;
ans=max(ans,mp[{i1-i2,j1-j2}]);
}
}
return ans;
}
void main()
{
int s,r;
vector<vector<int>> img1,img2;
cin>>s;
for(int i=0;i<s;i++)
{
img1.push_back(i);
img2.push_back(i);
r=largestOverlap(img1, img2)
cout<<r;
}