Cod sursă (job #751502)

Utilizator avatar alex_0747 Gheorghica Alexandru alex_0747 IP ascuns
Problemă Fotografie (clasele 9-10) Compilator cpp-32 | 0,98 kb
Rundă vs_11_12_dec Status evaluat
Dată 16 dec. 2023 11:22:22 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 l1, c1, l2, c2;

int main()
{
    int i, j, x, y, p, q, g;
    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;
             g = 1;
             for (x = i, p = 1; p <= l2 && g; x++, p++)
             {
                 for (y = j, q = 1; q <= c2 && g; y++, q++)
                    if (a[x][y] != b[p][q]) g = 0;
              //   cout << p << " " << q << "\n";
                 if (p < l2 && a[x + 1][j] != b[p + 1][1]) g = 0;
                 y = j;
                 if (g && p == l2 && q == c2 + 1) fout << i - 1 << " " << j - 1 << "\n";
             }
        }
    return 0;
}