Submission #3232049


Source Code Expand

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

int main() {
  int h , w;
  cin >> h >> w;
  vector<string> vec(h+2);
  vec.at(0) = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  vec.at(h+1) = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  for(int i=0;i<h;i++){
    cin >> vec.at(i+1);
  }
  if(w==1){
    for(int i=1;i<=h;i++){
      if(vec.at(i).at(0)=='.'){
        int s=0;
        if(vec.at(i-1).at(0)=='#') s++;
        if(vec.at(i+1).at(0)=='#') s++;
        cout <<s <<endl;
      }
      else{
        cout <<"#"<<endl;
      }
    }
  }
  else{
    for(int i=1;i<=h;i++){
      if(vec.at(i).at(0)=='.'){
        int s=0;
        if(vec.at(i-1).at(0)=='#') s++;
        if(vec.at(i-1).at(1)=='#') s++;
        if(vec.at(i).at(1)=='#') s++;
        if(vec.at(i+1).at(0)=='#') s++;
        if(vec.at(i+1).at(1)=='#') s++;
        cout <<s;
      }
      else{
        cout <<"#";
      }
      for(int j=1;j<w-1;j++){
        if(vec.at(i).at(j)=='.'){
          int s=0;
          if(vec.at(i-1).at(j-1)=='#') s++;
          if(vec.at(i-1).at(j)=='#') s++;
          if(vec.at(i-1).at(j+1)=='#') s++;
          if(vec.at(i).at(j-1)=='#') s++;
          if(vec.at(i).at(j+1)=='#') s++;
          if(vec.at(i+1).at(j-1)=='#') s++;
          if(vec.at(i+1).at(j)=='#') s++;
          if(vec.at(i+1).at(j+1)=='#') s++;
          cout <<s;
        }
        else{
        cout <<"#";
        }
      }
      if(vec.at(i).at(w-1)=='.'){
        int s=0;
        if(vec.at(i-1).at(w-2)=='#') s++;
        if(vec.at(i-1).at(w-1)=='#') s++;
        if(vec.at(i).at(w-2)=='#') s++;
        if(vec.at(i+1).at(w-2)=='#') s++;
        if(vec.at(i+1).at(w-1)=='#') s++;
        cout << s << endl;
      }
      else{
        cout << "#" <<endl;
      }
    }
  }
}

Submission Info

Submission Time
Task B - Minesweeper
User Fugitsune
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1858 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