#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[0][0];
long long p, q, z;
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;
z = 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 * z != 0)
cnt = 0;
}
}
}
if (cnt==1 || cnt==2) {
ans++;
}
}
}
printf("%d\n", ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
16708 KB |
Output is correct |
2 |
Correct |
0 ms |
16708 KB |
Output is correct |
3 |
Correct |
0 ms |
16708 KB |
Output is correct |
4 |
Correct |
0 ms |
16708 KB |
Output is correct |
5 |
Correct |
0 ms |
16708 KB |
Output is correct |
6 |
Correct |
0 ms |
16708 KB |
Output is correct |
7 |
Correct |
0 ms |
16708 KB |
Output is correct |
8 |
Correct |
0 ms |
16708 KB |
Output is correct |
9 |
Correct |
0 ms |
16708 KB |
Output is correct |
10 |
Correct |
4 ms |
16708 KB |
Output is correct |
11 |
Correct |
4 ms |
16708 KB |
Output is correct |
12 |
Correct |
4 ms |
16708 KB |
Output is correct |
13 |
Correct |
0 ms |
16708 KB |
Output is correct |
14 |
Correct |
5 ms |
16708 KB |
Output is correct |
15 |
Correct |
12 ms |
16708 KB |
Output is correct |
16 |
Correct |
4 ms |
16708 KB |
Output is correct |
17 |
Correct |
0 ms |
16708 KB |
Output is correct |
18 |
Correct |
0 ms |
16708 KB |
Output is correct |
19 |
Correct |
2 ms |
16708 KB |
Output is correct |
20 |
Correct |
0 ms |
16708 KB |
Output is correct |
21 |
Correct |
12 ms |
16708 KB |
Output is correct |
22 |
Correct |
11 ms |
16708 KB |
Output is correct |
23 |
Correct |
8 ms |
16708 KB |
Output is correct |
24 |
Correct |
0 ms |
16708 KB |
Output is correct |
25 |
Correct |
7 ms |
16708 KB |
Output is correct |
26 |
Correct |
0 ms |
16708 KB |
Output is correct |
27 |
Correct |
0 ms |
16708 KB |
Output is correct |
28 |
Correct |
3 ms |
16708 KB |
Output is correct |
29 |
Correct |
0 ms |
16708 KB |
Output is correct |
30 |
Correct |
3 ms |
16708 KB |
Output is correct |
31 |
Correct |
3 ms |
16708 KB |
Output is correct |
32 |
Correct |
0 ms |
16708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1854 ms |
16708 KB |
Output is correct |
2 |
Correct |
5840 ms |
16708 KB |
Output is correct |
3 |
Execution timed out |
10000 ms |
16704 KB |
Program timed out |
4 |
Halted |
0 ms |
0 KB |
- |