码迷,mamicode.com
首页 > 其他好文 > 详细

【CodeForces 699B】One Bomb

时间:2016-08-03 23:54:37      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

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",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",&ma[i]);
		for(int j=1;j<=m;j++){
			if(ma[i][j-1]==‘*‘){
				num++;
				r[i]++;
				c[j]++;
			}
		}
	}
	int ok=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			int s=r[i]+c[j];
			if(ma[i][j-1]==‘*‘)s--;
			if(s==num){
				ok=1;
				x=i;
				y=j;
			}
		}		
	if(ok)
	{
		puts("YES");
		printf("%d %d",x,y);
	}
	else printf("NO");
} 

  

【CodeForces 699B】One Bomb

标签:

原文地址:http://www.cnblogs.com/flipped/p/5734978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!