This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
int n,m,p,q;
int a[1010][1010];
int b[1010][1010];
int ans;
int main(){
int i,j,k,l;
double x,y;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++){
for(j=0;j<m;j++){
scanf("%d",&a[i][j]);
}
}
scanf("%d%d",&p,&q);
for(i=0;i<p;i++){
for(j=0;j<q;j++){
scanf("%d",&b[i][j]);
}
}
for(i=0;i<=n-p;i++){
for(j=0;j<=m-q;j++){
for(k=0;k<p;k++){
for(l=0;l<q;l++){
if(b[k][l]!=b[0][0])break;
}
if(l!=q)break;
}
if(k==p)ans++;
else{
if(a[i][j]==a[i+k][j+l])continue;
x=((double)b[0][0]-b[k][l])/((double)a[i][j]-a[i+k][j+l]);
y=b[0][0]-x*a[i][j];
for(k=0;k<p;k++){
for(l=0;l<q;l++){
if(x*a[i+k][j+l]+y<b[k][l]-(1e-7)||x*a[i+k][j+l]+y>b[k][l]+(1e-7))break;
}
if(l!=q)break;
}
if(k==p)ans++;
}
}
}
printf("%d",ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |