题意:给你一个棋盘的最终局面。

你的一次操作可以选择一些行和列,将它们的交叉点染黑,不能重复选择某行或者某列。问你是否能经过数次操作之后,达到目标局面。

就枚举所有黑点,如果该点行列都没被标记,就给它的行列新建一次操作的序号;否则如果只有行有操作标号,就把它付给列操作标号;对列亦然。

然后模拟一遍,看看结果是否和题目所给相同。

#include<cstdio>
#include<cstdlib>
using namespace std;
int n,m,num;
char a[55][55];
int b[55],c[55];
char d[55][55];
int main(){
//freopen("b.in","r",stdin);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i){
scanf("%s",a[i]+1);
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
if(a[i][j]=='#'){
if(!b[i] && !c[j]){
b[i]=c[j]=++num;
}
else if(!b[i] && c[j]){
b[i]=c[j];
}
else if(b[i] && !c[j]){
c[j]=b[i];
}
}
}
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
d[i][j]='.';
}
}
for(int k=1;k<=num;++k){
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
if(b[i]==c[j] && b[i]==k){
d[i][j]='#';
}
}
}
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
if(a[i][j]!=d[i][j]){
puts("No");
return 0;
}
}
}
puts("Yes");
return 0;
}

【推导】Codeforces Round #472 (rated, Div. 2, based on VK Cup 2018 Round 2) B. Mystical Mosaic的更多相关文章

  1. 【推导】【贪心】Codeforces Round #472 (rated, Div. 2, based on VK Cup 2018 Round 2) D. Riverside Curio

    题意:海平面每天高度会变化,一个人会在每天海平面的位置刻下一道痕迹(如果当前位置没有已经刻划过的痕迹),并且记录下当天比海平面高的痕迹有多少条,记为a[i].让你最小化每天比海平面低的痕迹条数之和. ...

  2. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) F 构造

    http://codeforces.com/contest/967/problem/F 题目大意: 有n个点,n*(n-1)/2条边的无向图,其中有m条路目前开启(即能走),剩下的都是关闭状态 定义: ...

  3. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) E 贪心

    http://codeforces.com/contest/967/problem/E 题目大意: 给你一个数组a,a的长度为n 定义:b(i) = a(1)^a(2)^......^a(i), 问, ...

  4. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) D 贪心

    http://codeforces.com/contest/967/problem/D 题目大意: 有n个服务器,标号为1~n,每个服务器有C[i]个资源.现在,有两个任务需要同时进行,令他为x1,x ...

  5. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)A. Protect Sheep

    http://codeforces.com/contest/948/problem/A   A. Protect Sheep Bob is a farmer. He has a large pastu ...

  6. Codeforces Round #470 (rated, Div. 1, based on VK Cup 2018 Round 1) 923D 947D 948E D. Picking Strings

    题: OvO http://codeforces.com/contest/947/problem/D 923D 947D 948E 解: 记要改变的串为 P1 ,记目标串为 P2  由变化规则可得: ...

  7. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1) C.Producing Snow

    题目链接  题意  每天有体积为Vi的一堆雪,所有存在的雪每天都会融化Ti体积,求出每天具体融化的雪的体积数. 分析 对于第i天的雪堆,不妨假设其从一开始就存在,那么它的初始体积就为V[i]+T[1. ...

  8. 【枚举】【二分】Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) D. Resource Distribution

    题意:有两个服务要求被满足,服务S1要求x1数量的资源,S2要求x2数量的资源.有n个服务器来提供资源,第i台能提供a[i]的资源.当你选择一定数量的服务器来为某个服务提供资源后,资源需求会等量地分担 ...

  9. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)

    A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

随机推荐

  1. D. Easy Problem(简单DP)

    题目链接:http://codeforces.com/contest/1096/problem/D 题目大意:给你一个字符串,然后再给你去掉每个字符串的每个字符的花费,然后问你使得字符中不再存在har ...

  2. 20165320 实验一 java环境的熟悉

    实验内容与步骤 一.java开发环境的熟悉 1.建立一个有关自己学号的目录 2.在当前文件下编译一个带包Hello.java文件 3.代码内容 package sq; import java.util ...

  3. 莫烦课程Batch Normalization 批标准化

    for i in range(N_HIDDEN): # build hidden layers and BN layers input_size = 1 if i == 0 else 10 fc = ...

  4. reshape中的-1

    >>> a = np.array([[1,2,3], [4,5,6]]) >>> np.reshape(a, (3,-1)) # the unspecified v ...

  5. python基础之命名空间

    前言 命名空间通俗的理解就是对象或变量的作用范围,在python中分为局部命令空间.模块命名空间和build-in全局命名空间. 局部命名空间 局部命名空间即在一个函数或一个类中起作用的变量或引用的字 ...

  6. Linux USB驱动学习总结(二)---- USB设备驱动

    USB 设备驱动: 一.USB 描述符:(存在于USB 的E2PROM里面) 1.  设备描述符:struct usb_device_descriptor 2.  配置描述符:struct usb_c ...

  7. TreeCollection2

    Tree Collection 2 Table of Contents Introduction Structure Interfaces Data Node structure Tree struc ...

  8. asp.net 获取音视频时长 的方法

    http://www.evernote.com/l/AHPMEDnEd65A7ot_DbEP4C47QsPDYLhYdYg/ 日志:   1.第一种方法:   调用:shell32.dll ,win7 ...

  9. 夜神模拟器调试android studio项目

    这几天为了android studio也是醉了,先是R文件丢失忙活一下午,各种百度谷歌,最后终于解决这个小问题,没想到在启动avd这个问题上更是棘手,网上的方法试了,主要有三种,上篇博文http:// ...

  10. HDU 3861 The King’s Problem(强连通分量+最小路径覆盖)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3861 题目大意: 在csdn王国里面, 国王有一个新的问题. 这里有N个城市M条单行路,为了让他的王国 ...