Submission #15370

#TimeUsernameProblemLanguageResultExecution timeMemory
15370myungwoo흑백 이미지 찾기 (kriii3_G)C++14
0 / 101
0 ms16708 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...