zoukankan      html  css  js  c++  java
  • Codeforces Round #483 (Div. 2) B. Minesweeper

    题目地址:http://codeforces.com/contest/984/problem/B

    题目大意:扫雷游戏,给你一个n*m的地图,如果有炸弹,旁边的八个位置都会+1,问这幅图是不是正确的。

    题解:把输入的地图转换为数字格式,自己重新按炸弹绘制一幅图,对比一下。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<string>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<set>
    #include<map>
    #include<stack>
    using namespace std;
    const int inf = 0x3f3f3f3f;
    int main()
    {
        int n, m;
        int map[150][150], co[150][150] = {0};
        scanf("%d%d", &n, &m);
        for (int i = 0; i < n; i++)
        {
            getchar();
            for (int j = 0; j < m; j++)
            {
                char cell;
                scanf("%c", &cell);
                if (cell == '*')
                {
                    map[i][j] = 10;
                    co[i][j] = 10;
                    co[i - 1][j - 1]++; co[i - 1][j]++; co[i - 1][j + 1]++;
                    co[i][j - 1]++; co[i][j + 1]++;
                    co[i + 1][j - 1]++; co[i + 1][j]++; co[i + 1][j + 1]++;
                }
                else if (cell == '.')
                    map[i][j] = 0;
                else
                    map[i][j] = cell - '0';
            }
        }
        int flag = 1;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (map[i][j] != co[i][j]&&co[i][j]<=8)
                {
                    flag = 0;
                    goto x;
                }
            }
        }
    x:
        if (flag == 0)
            printf("NO
    ");
        else
            printf("YES
    ");
        return 0;
    }
  • 相关阅读:
    pytorch空间变换网络
    Jittor 的Op, Var算子
    元算子卷积层实现
    Caffe实现概述
    Halide视觉神经网络优化
    旷视MegEngine数据加载与处理
    旷视MegEngine网络搭建
    旷视MegEngine基本概念
    Torchvision模型微调
    新的一天
  • 原文地址:https://www.cnblogs.com/Tangent-1231/p/9076578.html
Copyright © 2011-2022 走看看