This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma warning(disable:4996)
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cmath>
using std::swap;
using std::vector;
using std::max;
int n, m, r, c;
long long a[1000][1000];
long long b[1000][1000];
int main()
{
scanf("%d%d", &n, &m);
for (int i=0; i<n; i++) for (int j=0; j<m; j++) scanf("%lld", &a[i][j]);
scanf("%d%d", &r, &c);
for (int i=0; i<r; i++) for (int j=0; j<c; j++) scanf("%lld", &b[i][j]);
int ans = 0;
for (int i=0; i<=n-r; i++) {
for (int j=0; j<=m-c; j++) {
int cnt = 1;
long long ra = a[i][j];
long long rb = b[i][j];
long long p, q, k;
for (int k=0; k<r; k++) {
for (int l=0; l<c; l++) {
long long na = a[i+k][j+l];
long long nb = b[k][l];
if (cnt == 1) { // line
if (ra != na) {
p = rb - nb;
q = ra * nb - rb * na;
k = ra - na;
cnt = 2;
}
else {
if (rb != nb) // no solution
cnt = 0;
}
}
else if (cnt == 2) { // point: p, q given
if (na * p + q - nb * k != 0)
cnt = 0;
}
}
}
if (cnt==1 || cnt==2)
ans++;
}
}
printf("%d\n", ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |