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

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

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

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstdlib>
  4. #include<cstring>
  5. #include<cmath>
  6. #include<string>
  7. #include<algorithm>
  8. #include<vector>
  9. #include<queue>
  10. #include<set>
  11. #include<map>
  12. #include<stack>
  13. using namespace std;
  14. const int inf = 0x3f3f3f3f;
  15. int main()
  16. {
  17. int n, m;
  18. int map[][], co[][] = {};
  19. scanf("%d%d", &n, &m);
  20. for (int i = ; i < n; i++)
  21. {
  22. getchar();
  23. for (int j = ; j < m; j++)
  24. {
  25. char cell;
  26. scanf("%c", &cell);
  27. if (cell == '*')
  28. {
  29. map[i][j] = ;
  30. co[i][j] = ;
  31. co[i - ][j - ]++; co[i - ][j]++; co[i - ][j + ]++;
  32. co[i][j - ]++; co[i][j + ]++;
  33. co[i + ][j - ]++; co[i + ][j]++; co[i + ][j + ]++;
  34. }
  35. else if (cell == '.')
  36. map[i][j] = ;
  37. else
  38. map[i][j] = cell - '';
  39. }
  40. }
  41. int flag = ;
  42. for (int i = ; i < n; i++)
  43. {
  44. for (int j = ; j < m; j++)
  45. {
  46. if (map[i][j] != co[i][j]&&co[i][j]<=)
  47. {
  48. flag = ;
  49. goto x;
  50. }
  51. }
  52. }
  53. x:
  54. if (flag == )
  55. printf("NO\n");
  56. else
  57. printf("YES\n");
  58. return ;
  59. }

Codeforces Round #483 (Div. 2) B. Minesweeper的更多相关文章

  1. Codeforces Round #483 (Div. 2) B题

    B. Minesweeper time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  2. Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!]

    题目链接:http://codeforces.com/contest/984 A. Game time limit per test:2 seconds memory limit per test:5 ...

  3. Codeforces Round #483 (Div. 2)题解

    A. Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

  4. Codeforces Round #483 (Div. 2)C题

    C. Finite or not? time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  5. Codeforces Round #483 (Div. 2) C. Finite or not?

    C. Finite or not? time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  6. Codeforces Round #483 (Div. 2) D. XOR-pyramid

    D. XOR-pyramid time limit per test 2 seconds memory limit per test 512 megabytes input standard inpu ...

  7. Codeforces Round #483 (Div. 2)

    题目链接: https://cn.vjudge.net/contest/229761 A题: n个数字,两个人轮流去数字,直到剩下最后一个数字为止,第一个人希望剩下的数字最小,第二个人希望数字最大,最 ...

  8. Codeforces Round #483 Div. 1

    A:首先将p和q约分.容易发现相当于要求存在k满足bk mod q=0,也即b包含q的所有质因子.当然不能直接分解质因数,考虑每次给q除掉gcd(b,q),若能将q除至1则说明合法.但这个辣鸡题卡常, ...

  9. 【递推】Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!] D. XOR-pyramid

    题意:定义,对于a数组的一个子区间[l,r],f[l,r]定义为对该子区间执行f操作的值.显然,有f[l,r]=f[l,r-1] xor f[l+1,r].又定义ans[l,r]为满足l<=i& ...

随机推荐

  1. 极力推荐一个简单好用的C++JSON库

      极力推荐一个简单好用的C++JSON库CJsonObject,让使用json如使用C++原生的结构体那般方便,随心所欲.CJsonObject是个优秀的C++JSON库,也许会是你见过的最为简单易 ...

  2. SQLServer2000同步复制技术实现步骤

    SQLServer2000同步复制技术实现步骤 一. 预备工作 1.发布服务器,订阅服务器都创建一个同名的windows用户,并设置相同的密码,做为发布快照文件夹的有效访问用户 --管理工具 --计算 ...

  3. Python之assert断言语句

    关键字assert构成断言语句,主要是可以在我们书写一个新的程序时,可以使用它帮我们锁定bug范围. 表达式: assert 表达式 ‘窗口提示的信息’ 括号中的项目为选填项目,选填项目将会在表达式的 ...

  4. Wtm携手LayUI -- .netcore 开源生态我们是认真的!

    经过WTM团队和LayUI团队多次深入协商,双方于2019年7月29日在北京中国国际展览中心正式达成战略合作意向, 双方签署了战略合作框架协议,LayUI团队承诺使用WTM框架的任何项目都可以免费使用 ...

  5. centos yum 安装 mariadb

    1. 在 /etc/yum.repos.d/ 下建立 MariaDB.repo,输入内容 [mariadb] name=MariaDB baseurl=http://yum.mariadb.org/1 ...

  6. The introduction of the book American daily English notes (enlarged edition)

    After reading the book of American daily English notes written by Linkun Yang[1], I think I should a ...

  7. S3 Select for Java 使用记录

    背景 后台基本使用 Amazon 的全家桶(EC2.DynamoDB.S3.Step Fuction 等等)构建.现在需要根据访问者的 IP 确定访问者的国家或地区. 已知: 访问者 IP 一个 ip ...

  8. TP5使用API时不可预知的内部异常

    最常见的错误形式例如 controller不存在或者 action不存在之类的 我们第一时间想到的 就是 使用 try{}catch(){} 来捕获 例如: /** * show方法在common里定 ...

  9. LSTM+CRF维特比解码过程

    题目:给定长度为n的序列,标签数为m(标签值表示为1,2,....,m),发射概率矩阵E(n * m),其中E[i][j]表示第i个词预测为标签j的发射概率,转移概率矩阵T(m*m),其中T[i][j ...

  10. ES6中。类与继承的方法,以及与ES5中的方法的对比

    // 在ES5中,通常使用构造函数方法去实现类与继承 // 创建父类 function Father(name, age){ this.name = name; this.age = age; } F ...