Cod sursă (job #751561)

Utilizator avatar Latyn76 Tinica Alexandru Stefan Latyn76 IP ascuns
Problemă Fotografie (clasele 9-10) Compilator cpp-32 | 0,90 kb
Rundă vs_11_12_dec Status evaluat
Dată 16 dec. 2023 11:48:46 Scor 30
#include <bits/stdc++.h>
using namespace std;

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

int n, m, N, M;
string a[1005];
string b[1005];

string makeHash(int x, int y){
    string s;
    for(int i = x; i < x + n; i++){
        s += a[i].substr(y, m);
    }
    return s;
}

string makeHashb(int x, int y){
    string s;
    for(int i = x; i < x + n; i++){
        s += b[i].substr(y, m);
    }
    return s;
}

int main()
{
    fin >> N >> M;
    for(int i = 0; i < N; i++)
        fin >> a[i];
    fin >> n >> m;
    for(int i = 0; i < n; i++)
        fin >> b[i];
    string b = makeHashb(0, 0);
    cout << b << '\n';
    //cout << makeHash(0, 2);
    for(int i = 0; i < N - n + 1; i++){
        for(int j = 0; j < M - m + 1; j++){
            if(makeHash(i, j) == b)
                fout << i << ' ' << j << '\n';
        }
    }
    return 0;
}