Submission #1683750


Source Code Expand

Copy
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int H,W;
  scanf("%d%d",&H,&W);
  bool S[H+2][W+2];
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      S[i][j]=false;
    }
  }
  string temp;
  for (int i = 1; i <= H; i++) {
    std::cin >> temp;
    for (int j = 1; j <= W; j++) {
      if(temp[j-1]=='#'){
        S[i][j]=true;
      }else{
        S[i][j]=false;
      }
    }
  }

  int ans[H+2][W+2],bomb;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if(S[i][j]==true){
        ans[i][j]=-1;
      }else{
        bomb=0;
        for (int k = i; k < i+3; k++) {
          for (int z = j; z < j+3; z++) {
            if(S[k-1][z-1]==true){
              ++bomb;
            }
          }
        }
        ans[i][j]=bomb;
      }
    }
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if(ans[i][j]==-1){
        printf("#");
      }else{
        printf("%d",ans[i][j]);
      }
    }
    printf("\n");
  }
  return 0;
}

Submission Info

Submission Time
Task B - Minesweeper
User Marco3jp
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1163 Byte
Status
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main(int, const char**)’:
./Main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&H,&W);
                      ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 200 / 200 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 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
subtask_1_1.txt 1 ms 256 KB
subtask_1_10.txt 1 ms 256 KB
subtask_1_11.txt 1 ms 256 KB
subtask_1_12.txt 1 ms 256 KB
subtask_1_2.txt 1 ms 256 KB
subtask_1_3.txt 1 ms 256 KB
subtask_1_4.txt 1 ms 256 KB
subtask_1_5.txt 1 ms 256 KB
subtask_1_6.txt 1 ms 256 KB
subtask_1_7.txt 1 ms 256 KB
subtask_1_8.txt 1 ms 256 KB
subtask_1_9.txt 1 ms 256 KB