Untitled

 avatar
user_9000366
plain_text
8 days ago
2.4 kB
1
Indexable
// C
#include <bits/stdc++.h>
using namespace std;

#define ll          long long

void Init() {
    ios_base::sync_with_stdio(false),
            cin.tie(nullptr),
            cout.tie(nullptr);
#ifdef CLION
    freopen("moon-in.txt", "r", stdin);
    freopen("moon-out.txt", "w", stdout);
#else
    //  freopen("input.txt", "r", stdin);
#endif
}

void Mesh_JOO() {
    int n, m;
    cin >> n >> m;
    char grid[n][m];
    pair<int, int> st, en;
    st = {n, m};
    en = {0, 0};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '#') {
                st.first = min(i, st.first);
                st.second = min(j, st.second);
                en.first = max(i, en.first);
                en.second = max(j, en.second);
            }
        }
    }
    for (int i = st.first; i <= en.first; i++) {
        for (int j = st.second; j <= en.second; j++) {
            if (grid[i][j] == '.')
                return void(cout << "No");
        }
    }
    cout << "Yes";
}

int main() {
    Init();
    int t{1};
    // cin >> t;
    while (t--) {
        Mesh_JOO();
    }
    return 0;
}

//E
#include <bits/stdc++.h>
using namespace std;

#define ll          long long

void Init() {
    ios_base::sync_with_stdio(false),
            cin.tie(nullptr),
            cout.tie(nullptr);
#ifdef CLION
    freopen("moon-in.txt", "r", stdin);
    freopen("moon-out.txt", "w", stdout);
#else
    //  freopen("input.txt", "r", stdin);
#endif
}

void Mesh_JOO() {
    int n, m;
    cin >> n >> m;

    char a[n][n], b[m][m];
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
    for (int i = 0; i < m; ++i)
        for (int j = 0; j < m; ++j)
            cin >> b[i][j];
    for (int i = 0; i <= n - m; ++i)
        for (int j = 0; j <= n - m; ++j) {
            bool ok = true;
            for (int k = 0; k < m; ++k)
                for (int l = 0; l < m; ++l)
                    if (a[i + k][j + l] != b[k][l])
                        ok = false;
            if (ok) {
                cout << i + 1 << ' ' << j + 1 << '\n';
                return;
            }
        }
}

int main() {
    Init();
    int t{1};
    while (t--) {
        Mesh_JOO();
    }
    return 0;
}

Leave a Comment