이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma warning(disable:4996)
#include <stdio.h>
#include <algorithm>
using std::swap;
int n, m, r, c;
long long a[1000][1000];
long long b[1000][1000];
bool zero(double v)
{
const double eps = 1e-3;
return -eps <= v && v <= eps;
}
int rk(double m[][3])
{
int n = 3;
int r = 0;
for (int i=0; i<n; i++) {
bool f = false;
for (int j=r; j<n; j++) {
if (!zero(m[j][i])) {
f = true;
for (int k=0; k<n; k++)
swap(m[r][k], m[j][k]);
break;
}
}
if (f) {
for (int j=r+1; j<n; j++) {
double mul = m[j][i] / m[r][i];
for (int k=0; k<n; k++)
m[j][k] -= mul * m[r][k];
}
r++;
}
}
return r;
}
int rk(double m11, double m12, double m13, double m22, double m23, double m33)
{
double m21 = m12;
double m31 = m13;
double m32 = m23;
double m[3][3] = {m11, m12, m13, m21, m22, m23, m31, m32, m33};
return rk(m);
}
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++) {
long long ass = 0, bss = 0, as = 0, bs = 0, abs = 0, os = 0;
for (int k=0; k<r; k++) {
for (int l=0; l<c; l++) {
ass += a[i+k][j+l] * a[i+k][j+l];
abs += a[i+k][j+l] * b[k][l];
bss += b[k][l] * b[k][l];
as += a[i+k][j+l];
bs += b[k][l];
os++;
}
}
if (rk(ass, as, -abs, os, -bs, bss) <= 2)
ans++;
}
}
printf("%d\n", ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |