Submission #1684194


Source Code Expand

Copy
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long

int main()
{
    char str[52][52];
    int w, h;
    cin >> h >> w;

    REP(i, 52)REP(j, 52)str[i][j] = 0;

    REP(i, h) scanf("%s", str[i]);

    REP(i, h)
    {
        REP(j, w)
        {
            if(str[i][j] == '.')
            {
                str[i][j] = '0';
            }
        }
    }

    REP(i, h)
    {
        REP(j, w)
        {
            if(str[i][j] != '#') continue;
            if(i-1>=0 && j-1>=0)if(str[i-1][j-1]!='#')str[i-1][j-1]++;
            if(i-1>=0)if(str[i-1][j]!='#')str[i-1][j]++;
            if(i-1>=0 && j+1<w)if(str[i-1][j+1]!='#')str[i-1][j+1]++;
            if(j-1>=0)if(str[i][j-1]!='#')str[i][j-1]++;
            if(j+1>=0)if(str[i][j+1]!='#')str[i][j+1]++;
            if(i+1<h && j-1>=0)if(str[i+1][j-1]!='#')str[i+1][j-1]++;
            if(i+1<h)if(str[i+1][j]!='#')str[i+1][j]++;
            if(i+1<h && j+1<w)if(str[i+1][j+1]!='#')str[i+1][j+1]++;
        }
    }
    REP(i, h)
    {
        REP(j, w)
        {
            printf("%c", str[i][j]);
        }
        printf("\n");
    } 
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     REP(i, h) scanf("%s", str[i]);
                                  ^

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