题意:

在一个正常的点可以净化该行该列的所有细胞,判断是否可以净化所有的细胞,并且输出所选的点。

思路:

如果可以的话,一定会选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的更多相关文章

  1. Codeforces Round #192 (Div. 1) A. Purification 贪心

    A. Purification Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/probl ...

  2. Codeforces Round #192 (Div. 1) C. Graph Reconstruction 随机化

    C. Graph Reconstruction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/3 ...

  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 ...

  4. [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 ...

  5. Codeforces Round #192 (Div. 2) (330B) B.Road Construction

    题意: 要在N个城市之间修建道路,使得任意两个城市都可以到达,而且不超过两条路,还有,有些城市之间是不能修建道路的. 思路: 要将N个城市全部相连,刚开始以为是最小生成树的问题,其实就是一道简单的题目 ...

  6. Codeforces Round #192 (Div. 2) (330A) A. Cakeminator

    题意: 如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕. //cf 192 div2 #include <stdio.h> #include & ...

  7. Codeforces Round #192 (Div. 2)

    吐槽一下,这次的CF好简单啊. 可是我为什么这么粗心这么大意这么弱.把心沉下来,想想你到底想做什么! A 题意:O(-1) 思路:O(-1) #include <iostream> #in ...

  8. Codeforces Round #192 (Div. 2) A. Cakeminator

    #include <iostream> #include <vector> using namespace std; int main(){ int r,c; cin > ...

  9. Codeforces Round #192 (Div. 2) B. Road Construction

    #include <iostream> #include <vector> using namespace std; int main(){ int n,m; cin > ...

随机推荐

  1. String.format()

    System.out.println(String.format("sftp DownloadDir is: %s and new is %s", "哈哈",& ...

  2. 长春理工大学第十四届程序设计竞赛(重现赛)F

    F. Successione di Fixoracci 题目链接:https://ac.nowcoder.com/acm/contest/912/F 题目: 动态规划(Dynamic programm ...

  3. CentOS7系统安装

    CenOS7安装系统 镜像下载地址: http://isoredirect.centos.org/centos/7/isos/x86_64/ https://mirrors.aliyun.com/ce ...

  4. C语言:正负数之间取模运算(转载)

    如果 % 两边的操作数都为正数,则结果为正数或零:如果 % 两边的操作数都是负数,则结果为负数或零.C99 以前,并没有规定如果操作数中有一方为负数,模除的结果会是什么.C99 规定,如果 % 左边的 ...

  5. spring boot 2.0 thymeleaf调试时正常,打包后运行报错. 找不到模板文件.

    使用th:fragment  定义模板 使用 th:replace  来添加模板到需要的地方. 使用时发现一个非常奇怪的问题. 本机idea 调试环境一切正常, 但是打成jar包以后报错,提示找不到对 ...

  6. iOS组件化开发一使用source管理远端库升级(四)

    一.克隆远端库代码到本地选择master分支 1.克隆 2.代码会显示出你所有版本的tag 二.可以在Example目录下验证代码的正确行: cd 到库的文件夹然后 pod install comma ...

  7. c++快速排序算法

    c++快速排序算法 题目描述 利用快速排序算法将读入的NN个数从小到大排序后输出. 快速排序是信息学竞赛的必备算法之一.对于快速排序不是很了解的同学可以自行上网查询相关资料,掌握后独立完成.(C++选 ...

  8. Elasticsearch(一)开启外网访问

    1. 设置Elasticsearch对外访问的Host 修改Elasticsearch配置文件 elasticsearch.yml : network.host: 128.24.108.84  //在 ...

  9. C# 使用表达式树获取特性的值

    一.定义特性 /// <summary> /// 定义特性 /// </summary> [AttributeUsage(AttributeTargets.Field | At ...

  10. Ray聊天记录

    由于工作变动,Ray的文档.示例没有及时更新,深表歉意.在Ray升级后,性能较几个月前有了非常大的提升,也更具易用性.这是QQ交流群里大家的聊天记录,跟大家分享一下(由于时间仓促群里大家的聊天记录没有 ...