Submission #15523

#TimeUsernameProblemLanguageResultExecution timeMemory
15523tonyjjw흑백 이미지 찾기 (kriii3_G)C++98
33 / 101
10000 ms9052 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...