【模拟】Codeforces 699B One Bomb】的更多相关文章

题目链接: http://codeforces.com/problemset/problem/699/B 题目大意: N*M的图,*代表墙.代表空地.问能否在任意位置(可以是墙上)放一枚炸弹(能炸所在行和列),把所有的墙都炸掉.输出答案(不唯一). 题目思路: [模拟] N2预处理出每一行能炸多少墙,每一列能炸多少墙.再N2枚举放炸弹的位置看能炸掉的墙数目是否等于总数.注意如果炸弹位置上有墙要-1. // //by coolxxx ////<bits/stdc++.h> #include<…
题目地址:http://codeforces.com/contest/699/problem/B 题目大意: 一个矩阵,内容由‘.’和‘*’组成(‘.’ 空,‘*’ 代表墙),墙分布在不同位置,现找出一个位置放置 炸弹,炸弹能炸当前位置的一整行和一整列,如果炸弹的位置可以将所有的墙都炸掉,则输出 “YES” 并输出该位置,如果不存在这样一个位置,这输出“NO”.[炸弹可以放在空地或者墙上] 解题思路: 1. 对每行每列的墙进行统计,如果该位置为墙,则该行的墙数++同时该列的墙++,统计出所有墙的…
r[i],c[i]分别表示第i行有几个*,第i列有几个*. 枚举每个位置如果c[i]+r[j]-(本身是不是*)==总*数,则该位置即为答案. #include<cstdio> #include<cstring> #include<algorithm> #define N 10050 using namespace std; int n,m,r[N],c[N],x,y,num; char ma[N][N]; int main(){ scanf("%d%d&qu…
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, 然后接下来的t秒需要的蜡烛都燃烧着,超过t秒,每减少一秒灭一支蜡烛,好!!! 详细解释:http://blog.csdn.net/kalilili/article/details/43412385 */ #include <cstdio> #include <algorithm> #i…
题目地址:http://codeforces.com/problemset/problem/350/C /* 题意:机器人上下左右走路,把其他的机器人都干掉要几步,好吧我其实没读懂题目, 看着样例猜出来的,这题也蛮水的 模拟+贪心:sort一下,从最近的开始走 注意:坐标有一个为0的比普通的少一半的步骤,每次干掉一个要返回原来的位置 */ #include <cstdio> #include <iostream> #include <algorithm> #includ…
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单,依据公式得知折线一定是一上一下的,只要把两个相邻的坐标之间的折线填充就好 注意:坐标有可能为负数,所以移动值y初始化为1000,最后要倒过来输出 详细解释:http://blog.csdn.net/zhb1997/article/details/27877783 */ #include <cstd…
题目传送门 /* 模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢 题目倒是很长:) */ #include <cstdio> #include <algorithm> #include <iostream> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; ]; char s[MAXN]; int main(…
题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <stack> #include <cmath> #inc…
题目传送门 /* 模拟水题:给定n*m的空白方格,k次涂色,将(x,y)处的涂成黑色,判断第几次能形成2*2的黑色方格,若不能,输出0 很挫的判断四个方向是否OK */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <map> using namespace std; ; c…
B. One Bomb time limit per test1 second memory limit per test256 megabytes Problem Description You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupi…