【AtCoder ABC 075 B】Minesweeper
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
模拟,把#换成1
八个方向加一下就好。
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 50;
const int dx[8] = { 1,1,1,0,0,-1,-1,-1 };
const int dy[8] = { -1,0,1,-1,1,-1,0,1 };
int a[N + 10][N + 10],h,w;
string s;
int main()
{
/*freopen("F:\\rush.txt", "r", stdin);*/
cin >> h >> w;
for (int i = 1; i <= h; i++)
{
cin >> s;
for (int j = 1; j <= w; j++)
{
if (s[j - 1] == '#')
a[i][j] = 1;
else
a[i][j] = 0;
}
}
for (int i = 1;i <= h;i++)
for (int j = 1; j <= w; j++)
{
if (a[i][j] == 1)
putchar('#');
else
{
int num = 0;
for (int k = 0; k < 8; k++)
{
int tx = i + dx[k];
int ty = j + dy[k];
num += a[tx][ty];
}
printf("%d", num);
}
if (j == w)
puts("");
}
return 0;
}
【AtCoder ABC 075 B】Minesweeper的更多相关文章
- 【AtCoder ABC 075 D】Axis-Parallel Rectangle
[链接] 我是链接,点我呀:) [题意] 让你找到一个各边和坐标轴平行的矩形.使得这个矩形包含至少K个点. 且这个矩形的面积最小. [题解] 把所有的"关键点""都找出来 ...
- 【AtCoder ABC 075 C】Bridge
[链接] 我是链接,点我呀:) [题意] 让你求出桥的个数 [题解] 删掉这条边,然后看看1能不能到达其他所有的点就可以了 [代码] #include <bits/stdc++.h> us ...
- 【AtCoder ABC 075 A】One out of Three
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map轻松搞定 [代码] #include <bits/stdc++.h> using namespace std; ...
- 【AtCoder Regular Contest 082】Derangement
[链接]点击打开链接 [题意] 在这里写题意 [题解] 贪心. 连续一块的p[i]==i的话,对答案的贡献就应该为(这个连续块的长度+1)/2; 长度为1的也正确. (也即两两相邻的互换位置.) [错 ...
- 【Atcoder hbpc C 183】1=0.999...
Atcoder hbpc C 题意:给n个循环小数或者有限小数,问其中有多少个互不相同的. 思路:我的思路比较繁琐. 首先我们考虑分数化小数:假设原来的数是\(a.b(c)\),那么这个分数就是\(a ...
- 【AtCoder Regular Contest 080E】Young Maids [堆][线段树]
Young Maids Time Limit: 50 Sec Memory Limit: 512 MB Description 给定一个排列,每次选出相邻的两个放在队头,要求字典序最小. Input ...
- 【AtCoder Grand Contest 007E】Shik and Travel [Dfs][二分答案]
Shik and Travel Time Limit: 50 Sec Memory Limit: 512 MB Description 给定一棵n个点的树,保证一个点出度为2/0. 遍历一遍,要求每 ...
- 【AtCoder Grand Contest 001F】Wide Swap [线段树][拓扑]
Wide Swap Time Limit: 50 Sec Memory Limit: 512 MB Description Input Output Sample Input 8 3 4 5 7 8 ...
- 【AtCoder Grand Contest 012C】Tautonym Puzzle [构造]
Tautonym Puzzle Time Limit: 50 Sec Memory Limit: 256 MB Description 定义一个序列贡献为1,当且仅当这个序列 由两个相同的串拼接而成 ...
随机推荐
- php输出杨辉三角
php输出杨辉三角 一.截图 二.代码 <!DOCTYPE html> <html lang="en"> <head> <meta cha ...
- 洛谷P1720 月落乌啼算钱
目背景 (本道题目木有以藏歌曲……不用猜了……) <爱与愁的故事第一弹·heartache>最终章. 吃完pizza,月落乌啼知道超出自己的预算了.为了不在爱与愁大神面前献丑,只好还是硬着 ...
- kali之EtterCap学习
EtterCap是一个基于ARP地址欺骗方式的网络嗅探工具,主要适用于交换局域网络.借助于EtterCap嗅探软件,渗透测试人员可以检测网络内明文数据通讯的安全性,及时采取措施,避免敏感的用户名/密码 ...
- Model、ModelMap、ModelAndView的作用及区别
Model.ModelMap.ModelAndView的作用及区别 对于MVC框架,控制器controller执行业务逻辑 用于产生模型数据Model 视图view用来渲染模型数据 Model和Mod ...
- idea git ignore 插件
https://blog.csdn.net/qq_34590097/article/details/56284935
- 魔兽世界serverTrinitycore分析一:前言
一:简单介绍 项目地址:https://github.com/TrinityCore/TrinityCore 帖一段官网介绍吧 TrinityCore is a MMORPG Framework ba ...
- hdu 1233 还是畅通project (克鲁斯卡尔裸题)
还是畅通project Time Limit: 4000/2000 MS (Java/Others) M ...
- 19,tuple多元数组
#include <iostream> #include <tuple> using namespace std; void main() { char ch = 'a'; ; ...
- Flume的data flow(数据流)
data flow描述了数据从产生,传输.处理并最终写入目标的一条路径. 数据的采集的流向!如下图所示.
- 使用缓存Memcache存储更新微信access token
关键字:Memcache access_token 更新 存储 7200 本文介绍如何使用缓存Memcache存储及更新 access token的方法. 一.Access Token access_ ...