Codeforces Round #192 (Div. 2) (329A)C.Purification
题意:
在一个正常的点可以净化该行该列的所有细胞,判断是否可以净化所有的细胞,并且输出所选的点。
思路:
如果可以的话,一定会选n个点。 先判断每一行是否有正常细胞,然后判断每一列是否有,如果都没有肯定不能净化,然后输出每一行或者每一列的第一个正常细胞的位置就好。
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std; int n ;
char map[110][110]; int main()
{ cin>>n;
int i , x[110] , y[110] , j;
memset(x , 0 , sizeof(x));
memset(y , 0 , sizeof(y));
for(i = 0;i < n; i++ )
{
cin>>map[i];
for(j = 0; j < n; j++)
{
if(map[i][j] == '.')
{
x[i] = 1;
y[j] = 1;
}
}
}
int b = 0, c = 0;
for(i = 0; i < n; i++)
{
if(x[i] == 0) b = 1;
if(y[i] == 0) c = 1;
}
if(b&&c)
{
cout<<"-1"<<endl;
return 0 ;
}
if(b == 0)
{
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
{
if(map[i][j] == '.')
{
cout<<i+1<<" "<<j+1<<endl;
break;
}
}
return 0;
}
if(c == 0)
{
for(j = 0; j < n; j++)
for(i = 0; i < n; i++)
{
if(map[i][j] == '.')
{
cout<<i+1<<" "<<j+1<<endl;
break;
}
}
}
return 0;
}
Codeforces Round #192 (Div. 2) (329A)C.Purification的更多相关文章
- Codeforces Round #192 (Div. 1) A. Purification 贪心
A. Purification Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/probl ...
- Codeforces Round #192 (Div. 1) C. Graph Reconstruction 随机化
C. Graph Reconstruction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/3 ...
- Codeforces Round #192 (Div. 1) B. Biridian Forest 暴力bfs
B. Biridian Forest Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/pr ...
- [Codeforces Round #192 (Div. 2)] D. Biridian Forest
D. Biridian Forest time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #192 (Div. 2) (330B) B.Road Construction
题意: 要在N个城市之间修建道路,使得任意两个城市都可以到达,而且不超过两条路,还有,有些城市之间是不能修建道路的. 思路: 要将N个城市全部相连,刚开始以为是最小生成树的问题,其实就是一道简单的题目 ...
- Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
题意: 如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕. //cf 192 div2 #include <stdio.h> #include & ...
- Codeforces Round #192 (Div. 2)
吐槽一下,这次的CF好简单啊. 可是我为什么这么粗心这么大意这么弱.把心沉下来,想想你到底想做什么! A 题意:O(-1) 思路:O(-1) #include <iostream> #in ...
- Codeforces Round #192 (Div. 2) A. Cakeminator
#include <iostream> #include <vector> using namespace std; int main(){ int r,c; cin > ...
- Codeforces Round #192 (Div. 2) B. Road Construction
#include <iostream> #include <vector> using namespace std; int main(){ int n,m; cin > ...
随机推荐
- js获取radio选中索引值
<form name="form1" onsubmit="return foo()"> <input type="radio&quo ...
- asp.net core 自定义异常处理中间件
asp.net core 自定义异常处理中间件 Intro 在 asp.net core 中全局异常处理,有时候可能不能满足我们的需要,可能就需要自己自定义一个中间件处理了,最近遇到一个问题,有一些异 ...
- 【工具】读取proprtties工具类
获取properties内容: 基本的使用看网络上大多是这样的,使用时注意线程安全以及读写的实时性问题. 1.直接通过流读取(反射): InputStream inStream = this.get ...
- composer使用本地仓库
{ "repositories": { "sms": { "type": "path", "url" ...
- NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s!
今天测试环境一虚拟机运行中突然报错,,, 没见过的内核报错,于是google一番. 系统日志: Nov :: dev- kernel: NMI watchdog: BUG: soft lockup - ...
- gmap 获取瓦片数
在 gmap1.7版本中 gMapControl1.MapProvider.Projection.GetAreaTileCount(area, i, 0); 可用来获取到erea里i层的瓦片数量. 但 ...
- Coderforces 633D:Fibonacci-ish(map+暴力枚举)
http://codeforces.com/problemset/problem/633/D D. Fibonacci-ish Yash has recently learnt about the ...
- Larave使用composer安装无反应,提示“Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer”
按照Laravel文档的安装方式在windows上安装Laravel时,执行composer global require "laravel/installer". 然后命令行就显 ...
- c++学习书籍推荐《超越C++标准库:Boost库导论》下载
<超越C++标准库Boost库导论>不仅介绍了Boost库的功能.使用方法及注意事项,而且还深入讨论了Boost库的设计理念.解决问题的思想和技巧以及待处理的问题.因此,本书是一本了解Bo ...
- 使用Gitlab-CI 实现NetCore项目Docker化并部署到阿里云K8S
使用Gitlab-CI 实现NetCore项目Docker化并部署到阿里云K8S 先行条件: 1.了解NetCore项目基础命令,如dotnet publish 等几个常用命令. 2.了解Dock ...