Cod sursă (job #751881)

Utilizator avatar Razvan23 Razvan Mosanu Razvan23 IP ascuns
Problemă Fotografie (clasele 9-10) Compilator cpp-32 | 0.90 kb
Rundă Arhiva de probleme Status evaluat
Dată 17 dec. 2023 12:17:42 Scor 40
#include <bits/stdc++.h>
using namespace std;

ifstream fin("fotografie.in");
ofstream fout("fotografie.out");

char a[1005][1005], b[1005][1005];
int n, m, cnt, x, y;

void Verif(int i, int j)
{
    int ll, l;
    int aux, aux1;
    aux = i;
    aux1 = j;
    for(ll=1; ll<=y; ll++)
    {
        for(l=1; l<=x; l++)
            if(a[i][j] == b[l][ll]) i++;
            else return;
        i = aux;
        j++;
    }
    fout << aux - 1 << " " << aux1 - 1 << "\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    fin.tie(NULL);
    fout.tie(NULL);
    int i, j;
    fin >> n >> m;
    for(i=1; i<=n; i++)
        fin >> (a[i] + 1);
    fin >> x >> y;
    for(i=1; i<=x; i++)
        fin >> (b[i] + 1);
    for(i=1; i<=n-x+1; i++)
        for(j=1; j<=m-y+1; j++)
            if(a[i][j] == b[1][1]) Verif(i, j);
    fin.close();
    fout.close();
    return 0;
}