Submission #2461622


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int H, W;
    cin >> H >> W;
    auto S = make_v(H, W, '.');
    REP(i, 0, H) {
        REP(j, 0, W) {
            cin >> S[i][j];
        }
    }
    bool ok = true;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    REP(i, 0, H) {
        REP(j, 0, W) {
            bool ch = false;
            if (S[i][j] != '#') {
                continue;
            }
            REP(k, 0, 4) {
                int ni = i + dy[k], nj = j + dx[k];
                if (ni < 0 || ni >= H || nj < 0 || nj >= W) {
                    continue;
                }
                if (S[ni][nj] == '#') {
                    ch = true;
                }
            }
            if (!ch) {
                ok = false;
            }
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Submission Info

Submission Time
Task C - Grid Repainting 2
User commy
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1352 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 300 / 300 in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
in01.txt 1 ms 256 KB
in02.txt 1 ms 256 KB
in03.txt 1 ms 256 KB
in04.txt 1 ms 256 KB
in05.txt 1 ms 256 KB
in06.txt 1 ms 256 KB
in07.txt 1 ms 256 KB
in08.txt 1 ms 256 KB
in09.txt 1 ms 256 KB
in10.txt 1 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB