Submission #8874247


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int H, W;
    cin >> H >> W;

    char minesweeper[H][W];
    rep(h, H) {
        rep (w, W) {
            cin >> minesweeper[h][w];
        }
    }

    rep(h, H) {
        rep(w, W) {
            if (minesweeper[h][w] == '#') {
                continue;
            } else {
                int count = 0;
                for (int i = max(0, h - 1); i < min(h + 2, H); i++) {
                    for (int j = max(0, w - 1); j < min(w + 2, W); j++) {
                        if (i == h && j == w) {
                            continue;
                        } else if (minesweeper[i][j] == '#') {
                            count++;
                        }
                    }
                }
                minesweeper[h][w] = '0' + count;
            }
        }
    }

    rep(h, H) {
        rep (w, W) {
            cout << minesweeper[h][w];
        }
        cout << endl;
    }
}

Submission Info

Submission Time
Task B - Minesweeper
User tgzzzzz
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1057 Byte
Status AC
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_1.txt AC 1 ms 256 KB
subtask_1_10.txt AC 2 ms 256 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 1 ms 256 KB
subtask_1_2.txt AC 1 ms 256 KB
subtask_1_3.txt AC 1 ms 256 KB
subtask_1_4.txt AC 1 ms 256 KB
subtask_1_5.txt AC 1 ms 256 KB
subtask_1_6.txt AC 1 ms 256 KB
subtask_1_7.txt AC 1 ms 256 KB
subtask_1_8.txt AC 1 ms 256 KB
subtask_1_9.txt AC 1 ms 256 KB