Cod sursa(job #2672138)

Utilizator Alex_tz307Lorintz Alexandru Alex_tz307 Data 13 noiembrie 2020 10:34:45
Problema Barbar Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <bits/stdc++.h>

using namespace std;

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

int N, M;
queue < pair < int , int > > Q;
const int di[] = {-1, 0, 1, 0},
          dj[] = {0, 1, 0, -1};

inline bool inside(int lin, int col) {
    return lin > 0 && lin <= N  && col > 0 && col <= M;
}

void Lee(vector < vector < int > >& a) {
    while(!Q.empty()) {
        int i = Q.front().first,
            j = Q.front().second;
        Q.pop();
        for(int k = 0; k < 4; ++k) {
            int iv = i + di[k],
                jv = j + dj[k];
            if(inside(iv, jv) && a[iv][jv] == 0) {
                a[iv][jv] = a[i][j] + 1;
                Q.emplace(iv, jv);
            }
        }
    }
    for(int i = 1; i <= N; ++i)
        for(int j = 1; j <= M; ++j)
            --a[i][j];
}

int main() {
    fout << -1;
}