#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
int a[105][105], b[105][105];
int n, m, r, c;
bool ccw(pi a, pi b, pi c){
int dx1 = b.first - a.first;
int dy1 = b.second- a.second;
int dx2 = c.first - a.first;
int dy2 = c.second - a.second;
return 1ll * dx1 * dy2 != 1ll * dy1 * dx2;
}
vector<pi> v;
bool compare(int x, int y){
v.clear();
for(int i=1; i<=r; i++){
for(int j=1; j<=c; j++){
v.push_back(pi(a[x+i-1][y+j-1], b[i][j]));
}
}
for(int i=0; i<(int)v.size() - 2; i++){
if(ccw(v[i],v[i+1],v[i+2]) == 0){
continue;
}
return 0;
}
for(int i=0; i<(int)v.size()-1; i++){
if(v[i].first == v[i+1].first && v[i].second != v[i+1].second){
return 0;
}
}
return 1;
}
int main(){
scanf("%d %d",&n,&m);
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
scanf("%d",&a[i][j]);
}
}
scanf("%d %d",&r,&c);
for(int i=1; i<=r; i++){
for(int j=1; j<=c; j++){
scanf("%d",&b[i][j]);
}
}
int ret = 0;
for(int i=1; i<=n-r+1; i++){
for(int j=1; j<=m-c+1; j++){
if(compare(i,j)) ret++;
}
}
printf("%d",ret);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1296 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1296 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |