Pagini recente »
Borderou de evaluare (job #220171)
|
Istoria paginii runda/simulare_casi_11-12/clasament
|
Istoria paginii runda/2020-05-09-clasa-5-tema-37
|
Rating liviu morjolic (lyywww)
|
Cod sursă (job #397093)
Cod sursă (job
#397093)
#include <fstream>
using namespace std;
ifstream fin("fotografie.in");
ofstream fout("fotografie.out");
char a[1001][1001],b[1001][1001];
int n,m,p,q,suma,n1,m1,slocal,k;
int main()
{
fin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
fin>>a[i][j];
fin>>p>>q;
for(int i=1;i<=p;i++)
for(int j=1;j<=q;j++)
{
fin>>b[i][j];
suma+=b[i][j];
}
n1=n-p+1;m1=m-q+1;
for(int i=1;i<=n1;i++)
for(int j=1;j<=m1;j++)
{
for(int r=i;r<(i+p);r++)
for(int g=j;g<(j+q);g++)
slocal+=a[r][g];
if(slocal == suma)
{
for(int r=i;r<(i+p);r++)
for(int g=j;g<(j+q);g++)
if(a[r][g]==b[r-i+1][g-j+1]) k++;
if(k==p*q) fout<<i-1<<" "<<j-1<<endl;
k=0;
}
slocal=0;
}
}
/*
r g i j p q
1 3 1 3 3 3
ab aba ccb 0 2
cd cdc acd 3 1
bb bcb abb 3 3
a ababa ab
c cdcdc bd
b bcbcb da
aba
cdc
bcb
*/