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[][], co[][] = {};
- scanf("%d%d", &n, &m);
- for (int i = ; i < n; i++)
- {
- getchar();
- for (int j = ; j < m; j++)
- {
- char cell;
- scanf("%c", &cell);
- if (cell == '*')
- {
- map[i][j] = ;
- co[i][j] = ;
- co[i - ][j - ]++; co[i - ][j]++; co[i - ][j + ]++;
- co[i][j - ]++; co[i][j + ]++;
- co[i + ][j - ]++; co[i + ][j]++; co[i + ][j + ]++;
- }
- else if (cell == '.')
- map[i][j] = ;
- else
- map[i][j] = cell - '';
- }
- }
- int flag = ;
- for (int i = ; i < n; i++)
- {
- for (int j = ; j < m; j++)
- {
- if (map[i][j] != co[i][j]&&co[i][j]<=)
- {
- flag = ;
- goto x;
- }
- }
- }
- x:
- if (flag == )
- printf("NO\n");
- else
- printf("YES\n");
- return ;
- }
Codeforces Round #483 (Div. 2) B. Minesweeper的更多相关文章
- Codeforces Round #483 (Div. 2) B题
B. Minesweeper time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 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 ...
- Codeforces Round #483 (Div. 2)题解
A. Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #483 (Div. 2)
题目链接: https://cn.vjudge.net/contest/229761 A题: n个数字,两个人轮流去数字,直到剩下最后一个数字为止,第一个人希望剩下的数字最小,第二个人希望数字最大,最 ...
- Codeforces Round #483 Div. 1
A:首先将p和q约分.容易发现相当于要求存在k满足bk mod q=0,也即b包含q的所有质因子.当然不能直接分解质因数,考虑每次给q除掉gcd(b,q),若能将q除至1则说明合法.但这个辣鸡题卡常, ...
- 【递推】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& ...
随机推荐
- 极力推荐一个简单好用的C++JSON库
极力推荐一个简单好用的C++JSON库CJsonObject,让使用json如使用C++原生的结构体那般方便,随心所欲.CJsonObject是个优秀的C++JSON库,也许会是你见过的最为简单易 ...
- SQLServer2000同步复制技术实现步骤
SQLServer2000同步复制技术实现步骤 一. 预备工作 1.发布服务器,订阅服务器都创建一个同名的windows用户,并设置相同的密码,做为发布快照文件夹的有效访问用户 --管理工具 --计算 ...
- Python之assert断言语句
关键字assert构成断言语句,主要是可以在我们书写一个新的程序时,可以使用它帮我们锁定bug范围. 表达式: assert 表达式 ‘窗口提示的信息’ 括号中的项目为选填项目,选填项目将会在表达式的 ...
- Wtm携手LayUI -- .netcore 开源生态我们是认真的!
经过WTM团队和LayUI团队多次深入协商,双方于2019年7月29日在北京中国国际展览中心正式达成战略合作意向, 双方签署了战略合作框架协议,LayUI团队承诺使用WTM框架的任何项目都可以免费使用 ...
- centos yum 安装 mariadb
1. 在 /etc/yum.repos.d/ 下建立 MariaDB.repo,输入内容 [mariadb] name=MariaDB baseurl=http://yum.mariadb.org/1 ...
- 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 ...
- S3 Select for Java 使用记录
背景 后台基本使用 Amazon 的全家桶(EC2.DynamoDB.S3.Step Fuction 等等)构建.现在需要根据访问者的 IP 确定访问者的国家或地区. 已知: 访问者 IP 一个 ip ...
- TP5使用API时不可预知的内部异常
最常见的错误形式例如 controller不存在或者 action不存在之类的 我们第一时间想到的 就是 使用 try{}catch(){} 来捕获 例如: /** * show方法在common里定 ...
- LSTM+CRF维特比解码过程
题目:给定长度为n的序列,标签数为m(标签值表示为1,2,....,m),发射概率矩阵E(n * m),其中E[i][j]表示第i个词预测为标签j的发射概率,转移概率矩阵T(m*m),其中T[i][j ...
- ES6中。类与继承的方法,以及与ES5中的方法的对比
// 在ES5中,通常使用构造函数方法去实现类与继承 // 创建父类 function Father(name, age){ this.name = name; this.age = age; } F ...