Cod sursă (job #751445)

Utilizator avatar alex_0747 Gheorghica Alexandru alex_0747 IP ascuns
Problemă Fotografie (clasele 9-10) Compilator cpp-32 | 0,87 kb
Rundă vs_11_12_dec Status evaluat
Dată 16 dec. 2023 11:08:40 Scor 0
#include <bits/stdc++.h>
using namespace std;

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

char a[1005][1005], b[1005][1005];
int l1, c1, l2, c2;

int main()
{
    int i, j, x, y, p, q;
    fin >> l1 >> c1;
    for (i = 1; i <= l1; i++)
        fin >> (a[i] + 1);
    fin >> l2 >> c2;
    for (i = 1; i <= l2; i++)
        fin >> (b[i] + 1);
    for (i = 1; i <= l1 - l2 + 1; i++)
    {
        for (j = 1; j <= c1 - c2 + 1; j++)
        {
             x = i; y = j; p = q = 1;
             for ( ; p <= l2 && a[x][y] == b[p][q]; y = j, q = 1)
             {
                    for (; q <= c2 && a[x][y] == b[p][q]; y++, q++)
                     ;
                    if (p == l2 && q == 1 + c2)
                        fout << i - 1 << " " << j - 1 << "\n";
                    x++; p++;
            }
        }
    }
    return 0;
}