Pentru această operație este nevoie să te autentifici.
Cod sursă (job #547189)
Utilizator |
|
IP | ascuns |
---|---|---|---|
Problemă | Fotografie (clasele 9-10) | Compilator | cpp | 1,10 kb |
Rundă | lasm_19_03_2020_cl_12_a | Status | evaluat |
Dată | 19 mar. 2020 18:29:57 | Scor | 30 |
#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,diferenta,diflocal;
int main()
{
ios_base::sync_with_stdio(0);
fin.tie(NULL);
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++)
{
slocal=0;
for(int r=i;r<(i+p);r++)
for(int g=1;g<q;g++)
slocal+=a[r][g];
for(int j=1;j<=m1;j++)
{
for(int o=i;o<(i+p);o++)
{
slocal-=a[o][j-1];
slocal+=a[o][j+q-1];
}
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;
}
}
}
}
/*
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
*/