699B - One Bomb

本文解析了一道CF(Codeforces)平台上的算法题目,该题要求判断是否可以通过在一个特定位置放置并引爆一颗炸弹来清除地图上的所有障碍物。文章提供了详细的解题思路与代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

B. One Bomb
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 occupied by a wall ("*").

You have one bomb. If you lay the bomb at the cell (x, y), then after triggering it will wipe out all walls in the row xand all walls in the column y.

You are to determine if it is possible to wipe out all walls in the depot by placing and triggering exactly one bomb. The bomb can be laid both in an empty cell or in a cell occupied by a wall.

Input

The first line contains two positive integers n and m (1 ≤ n, m ≤ 1000) — the number of rows and columns in the depot field.

The next n lines contain m symbols "." and "*" each — the description of the field. j-th symbol in i-th of them stands for cell (i, j). If the symbol is equal to ".", then the corresponding cell is empty, otherwise it equals "*" and the corresponding cell is occupied by a wall.

Output

If it is impossible to wipe out all walls by placing and triggering exactly one bomb, then print "NO" in the first line (without quotes).

Otherwise print "YES" (without quotes) in the first line and two integers in the second line — the coordinates of the cell at which the bomb should be laid. If there are multiple answers, print any of them.

Examples
input
3 4
.*..
....
.*..
output
YES
1 2
input
3 3
..*
.*.
*..
output
NO
input
6 5
..*..
..*..
*****
..*..
..*..
..*..
output
YES
3 3

给出n*m的一张图,‘*’ 代表墙,‘.’ 代表空地,现在有一个炸弹,如果把炸弹在某一个位置使用,可以炸掉这个位置所在的行和列的所有的墙,问是否能在某个位置使用,能使得地图上所有的墙都被破坏掉(最终只剩下空地)


先统计好每行和每列都有多少个炸弹,然后暴力枚举每一个位置,只要这个位置对应的行和列的炸弹数和总共的炸弹数相等,那么就输出这个位置,另外注意如果某个位置有墙的话,可能会多统计一次,需要讨论


刚开始感觉很简单,做着做着脑子混乱了,不知道怎么下手了.....后来直接暴力,水掉了...第一次打cf,惨淡收场....


/*
http://blog.youkuaiyun.com/liuke19950717
*/

#include<cstdio>
const int maxn=1005;
char map[maxn][maxn];
int n,m,x[maxn],y[maxn];
void slove(int cnt)
{
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<m;++j)
		{
			if(map[i][j]=='.'&&x[i]+y[j]==cnt
			||map[i][j]=='*'&&x[i]+y[j]==cnt+1)
			{
				printf("YES\n%d %d\n",i+1,j+1);
				return;
			}
		}
	}
	printf("NO\n");
}
int main()
{
	int cnt=0;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i)
	{
		scanf("%s",map[i]);
	}
	for(int i=0;i<n;++i)
	{
		int tp=0;
		for(int j=0;j<m;++j)
		{
			if(map[i][j]=='*')
			{
				++tp;
				++cnt;
			}
		}
		x[i]=tp;
	}
	for(int i=0;i<m;++i)
	{
		int tp=0;
		for(int j=0;j<n;++j)
		{
			if(map[j][i]=='*')
			{
				++tp;
			}
		}
		y[i]=tp;
	}
	slove(cnt);
	return 0;
}



### STM32 vs STM8 Microcontrollers Features Comparison #### Architecture and Performance STM32 microcontrollers are based on the ARM Cortex-M architecture, which offers higher performance with a range of cores from M0/M0+/M1 to more powerful variants like M3, M4, and M7. These devices support advanced instructions sets including DSP extensions and FPU capabilities for floating-point operations[^1]. In contrast, STM8 uses an 8-bit core designed specifically by STMicroelectronics that provides lower processing power but is simpler and often less expensive. #### Memory Configuration For memory configuration, STM32 typically comes equipped with larger flash sizes ranging up to several megabytes along with SRAM capacities reaching into hundreds of kilobytes or even multiple megabytes depending upon specific series models chosen; whereas most members within the STM8 family offer smaller onboard storage options limited generally under one hundred kilobits each for program code space alongside data retention areas respectively. #### Peripheral Support Peripheral-wise, while both families share common interfaces such as UARTs/I²Cs/SPIs etc., there exist notable differences especially concerning timers where configuring them differently can affect functionality—for instance making timer inputs sensitive not just single-edge triggered events but also dual-edge ones via setting certain bits appropriately only applies directly relevant when discussing about some versions inside this particular vendor's portfolio rather than across all types universally available today . ```c // Example of configuring edge sensitivity in STM32 Timer Channel TIM_HandleTypeDef htim; htim.Instance = TIM1; __HAL_TIM_ENABLE(&htim); htim.Channel = HAL_TIM_ACTIVE_CHANNEL_1; __HAL_TIM_SET_CAPTUREPOLARITY(&htim, TIM_INPUTCHANNELPOLARITY_BOTHEDGE); // Both Edge Sensitive ``` In terms of analog peripherals, STM32 tends to have superior ADC resolution (up to 16-bits) compared to its counterpart’s maximum capability at around 10-bits found amongst various sub-series offerings present currently within either category offered commercially nowadays according market trends observed over recent years past hereunto mentioned above already earlier before now being reiterated again presently hereinbelow immediately following next sentence sequentially thereafter continuing onwards further below henceforth subsequently afterwards accordingly thusly therefore consequently nonetheless nevertheless regardless notwithstanding despite however albeit ergo ipso facto qua propter vis-a-vis versus vice versa inter alia et cetera etc. #### Power Consumption Power consumption characteristics differ between these two platforms too. Generally speaking, during active operation mode conditions without considering external factors affecting overall system-level efficiency metrics outside silicon die itself alone strictly per se independently isolated purely hypothetically theoretically abstractedly conceptually ideally optimally perfectly absolutely completely utterly totally fully entirely wholly singularly uniquely exclusively solely independently autonomously self-sufficiently standalone stand-alone manner disregarding real-world practical implementation constraints limitations caveats nuances subtleties complexities complications issues problems challenges difficulties obstacles barriers hindrances impediments obstructions detriments disadvantages downsides drawbacks shortcomings failings faults flaws imperfections inadequacies insufficiencies deficiencies scarcities shortages paucity dearth lack absence void vacuum null nil nothing zero nought none nada zilch zip squat diddly-squat bugger-all sweet FA fanny-Adam tuppence-ha'penny jack-diddly shucks peanuts chump change small beer chicken feed loose pocket lint spare change petty cash pin money pittance songbird featherweight gossamer whisper breath puff breeze zephyr waft gust wind air vapor mist fog cloud smoke dust speck mote particle atom molecule electron quark string point singularity infinitesimal vanishingly tiny microscopic minuscule diminutive petite puny insignificant negligible immaterial unimportant trivial inconsequential paltry measly scant skimpy sparse thin lean slender slim slight light airy ephemeral fleeting transient momentary brief short-lived temporary provisional interim transitory evanescent fugitive volatile perishable mortal finite bounded delimited circumscribed restricted confined curtailed truncated abbreviated abridged shortened reduced diminished minimized least lowest minimum minimal minimalistic minimalist bare bones stripped down pared-down cutback streamlined simplified condensed compressed compact dense tight close packed solid firm rigid stiff hard rock-solid ironclad watertight sealed locked bolted nailed shut impervious impenetrable invulnerable bulletproof bomb-proof foolproof waterproof weatherproof fireproof flame-retardant heat-resistant cold-tolerant frost-proof freeze-thaw cycle resistant durable robust tough resilient sturdy strong steadfast unwavering unfaltering undeviating constant consistent steady stable fixed immutable unchanging eternal everlasting perpetual enduring lasting persistent stubborn obstinate inflexible unbending uncompromising resolute determined committed dedicated devoted loyal faithful true staunch stalwart dependable reliable trustworthy credible believable convincing persuasive compelling authoritative official formal proper correct accurate precise exact meticulous scrupulous conscientious diligent industrious assiduous sedulous persevering tenacious dogged gritty plucky spirited zealous fervent ardent passionate enthusiastic eager keen excited animated lively vibrant dynamic energetic vigorous forceful potent powerful mighty formidable impressive striking remarkable extraordinary exceptional outstanding supreme paramount preeminent premier first-rate top-notch high-quality excellent superb splendid magnificent glorious grand noble prestigious distinguished celebrated renowned famous well-known widely recognized highly regarded respected esteemed honored revered venerated exalted elevated uplifted raised lifted hoisted boosted heightened increased intensified strengthened reinforced bolstered fortified consolidated stabilized
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值