Created
September 29, 2012 12:52
-
-
Save brickgao/3803907 to your computer and use it in GitHub Desktop.
Codeforces Round 141 (Div. 2) B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//By Brickgao | |
#include <iostream> | |
#include <cstdio> | |
#include <cstring> | |
#include <cmath> | |
#include <cstdlib> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int a[110][110], b[110][110]; | |
int na, ma, nb, mb; | |
int make(int x, int y) | |
{ | |
int ans = 0; | |
for(int i = 1; i <= na; i++) | |
for(int j = 1; j <= ma; j++) | |
{ | |
if(i + x > 0 && j + y > 0) | |
{ | |
ans += a[i][j] * b[i + x][j + y]; | |
} | |
} | |
return ans; | |
} | |
int main() | |
{ | |
int recx, recy, max = -1; | |
char ch; | |
int mmax, nmax; | |
cin >> na >> ma; | |
for(int i = 1; i <= na; i++) | |
{ | |
getchar(); | |
for(int j = 1; j <= ma; j++) | |
{ | |
ch = getchar(); | |
a[i][j] = (int)ch - 48; | |
} | |
} | |
cin >> nb >> mb; | |
for(int i = 1; i <= nb; i++) | |
{ | |
getchar(); | |
for(int j = 1; j <= mb; j++) | |
{ | |
ch = getchar(); | |
b[i][j] = (int)ch - 48; | |
} | |
} | |
if(ma > mb) mmax = ma; else mmax = mb; | |
if(na > nb) nmax = na; else nmax = nb; | |
for(int i = 1 - nmax; i <= nmax - 1; i++) | |
for(int j = 1 - mmax; j <= mmax - 1; j++) | |
{ | |
int tmp = make(i, j); | |
if(tmp > max) | |
{ | |
recx = i; | |
recy = j; | |
max = tmp; | |
} | |
} | |
printf("%d %d\n", recx, recy); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment