https://codeforc.es/contest/1194/problem/B

好像也没什么思维,就是一个水题,不过蛮有趣的。意思是找缺黑色最少的行列十字。用O(n)的空间预处理掉一维,然后用O(n)的时间根据另一维计算出答案。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll; int n, m;
string g[50005];
int rq[50005]; int main() {
#ifdef Yinku
freopen("Yinku.in", "r", stdin);
//freopen("Yinku.out", "w", stdout);
#endif // Yinku
int q;
while(~scanf("%d", &q)) {
while(q--) {
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++) {
cin >> g[i];
g[i] = '$' + g[i];
}
int minans = n * m;
for(int i = 1; i <= n; i++) {
rq[i] = 0;
for(int j = 1; j <= m; j++) {
if(g[i][j] == '.') {
rq[i]++;
}
}
}
for(int j = 1; j <= m; j++) {
int cq = 0;
for(int i = 1; i <= n; i++) {
if(g[i][j] == '.') {
cq++;
}
}
for(int i = 1; i <= n; i++) {
minans = min(minans, rq[i] + cq - (g[i][j] == '.'));
}
}
printf("%d\n",minans);
}
}
}

Codeforces - 1194B - Yet Another Crosses Problem - 水题的更多相关文章

  1. Codeforces 1194B. Yet Another Crosses Problem

    传送门 直接枚举填满哪一行,然后看看这一行填满以后哪一列最小 这个预处理一下 $cnt[i]$ 表示初始时第 $i$ 列有几个位置填满就可以做到 $O(m)$ 对于所有情况取个 $min$ 就是答案, ...

  2. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  3. Educational Codeforces Round 7 A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...

  4. Codeforces Testing Round #12 A. Divisibility 水题

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

  5. Codeforces Beta Round #37 A. Towers 水题

    A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...

  6. hdu-5867 Water problem(水题)

    题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  7. codeforces 677A A. Vanya and Fence(水题)

    题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  8. CodeForces 690C1 Brain Network (easy) (水题,判断树)

    题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...

  9. poj 1658 Eva's Problem(水题)

    一.Description Eva的家庭作业里有很多数列填空练习.填空练习的要求是:已知数列的前四项,填出第五项.因为已经知道这些数列只可能是等差或等比数列,她决定写一个程序来完成这些练习. Inpu ...

随机推荐

  1. 《图解HTTP》阅读总结

    前言:<图解HTTP>是一本图文并茂的好书,讲解地很详尽.目前我只完整地读了一遍,很多地方知其然不知其所以然,接下来打算抽空再读一次.这篇博文只是做个粗略记录,第二遍读完会再来编辑细化. ...

  2. VS #include 【bits/bstdc++.h】出错

    目录 1. 本文地址 2. 按 3. 操作步骤 1. 本文地址 博客园:https://www.cnblogs.com/coco56/p/11163142.html 简书:https://www.ji ...

  3. Solr从数据库导入数据(DIH)

    一. 数据导入(DataImportHandler-DIH) DIH 是solr 提供的一种针对数据库.xml/HTTP.富文本对象导入到solr 索引库的工具包.这里只针对数据库做介绍. A.准备以 ...

  4. 如何使您的Wifi路由器更安全,网络安全专家告诉您!

    中国知名“黑客”教父,网络安全专家郭盛华曾说过,Wifi路由器这样设置最安全.因为无线路由器都有不同的接口,不同的设置方式以及可以调整的不同设置.在本文中,我将探讨TP-LinkArcher的界面.您 ...

  5. 51nod 1028 大数乘法 V2 【FFT模板题】

    题目链接 模板题.. #include<bits/stdc++.h> using namespace std; typedef int LL; typedef double db; nam ...

  6. 百度编辑器UEditor使用总结

    官网下载地址:http://ueditor.baidu.com/website/download.html 我下载的是jsp版本,下载后将整个目录复制到项目的js包下,然后将jsp包下的lib下的ja ...

  7. fiddler常见问题

    捕获https: tools>options https>decrypt https traffic :安装证书捕获客户端请求: tools>options connections& ...

  8. Xenu Link Sleuth 简单好用的链接测试工具

    XenuLink Sleuth 名词介绍 “Xenu链接检测侦探”是被广泛使用的死链接检测工具.可以检测到网页中的普通链接.图片.框架.插件.背景.样式表.脚本和java程序中的链接. 那么神马时候出 ...

  9. elk+kafka+zookeeper+filebeat安装

    ElasticSearch6.0 ElasticSearch6.0安装 #依赖jdk8 rpm -ivh elasticsearch-.rpm vim /etc/elasticsearch/elast ...

  10. Hive学习之路(三)Hive处理中文乱码

    Hive注释中文乱码 创建表的时候,comment说明字段包含中文,表成功创建之后,中文说明显示乱码 create external table movie( userID int comment ' ...