hdu 1937 Finding Seats
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 889 Accepted Submission(s): 290
The movie theater has R rows of C seats each, and they can see a map with the currently available seats marked. They decided that seating close to each other is all that matters, even if that means seating in the front row where the screen is so big it’s impossible to see it all at once. In order to have a formal criteria, they thought they would buy seats in order to minimize the extension of their group.
The extension is defined as the area of the smallest rectangle with sides parallel to the seats that contains all bought seats. The area of a rectangle is the number of seats contained in it.
They’ve taken out a laptop and pointed at you to help them find those desired seats.
Input is terminated with R = C = K = 0.
...XX
.X.XX
XX...
5 6 6
..X.X.
.XXX..
.XX.X.
.XXX.X
.XX.XX
0 0 0
9
#include <iostream>
#include <cstdio>
#define MAX 300
using namespace std;
int r,c,k;
int sum[MAX + ][MAX + ];
inline int get(int l1,int l2,int r1,int r2) {
return sum[l2][r2] - sum[l1 - ][r2] - sum[l2][r1 - ] + sum[l1 - ][r1 - ];
}
int main() {
while(~scanf("%d%d%d",&r,&c,&k) && r && c && k) {
int ans = r * c + ;
for(int i = ;i <= r;i ++) {
getchar();
for(int j = ;j <= c;j ++) {
char ch = getchar();
if(ch == '.') sum[i][j] = ;
else sum[i][j] = ;
sum[i][j] += sum[i - ][j] + sum[i][j - ] - sum[i - ][j - ];
}
}
for(int i = ;i <= r;i ++) {
for(int j = ;j <= r;j ++) {
int left = ,right = ;
while(right <= c && left <= right) {
if(get(i,j,left,right) < k) right ++;
else {
ans = min(ans,(j - i + ) * (right - left + ));
left ++;
}
}
}
}
printf("%d\n",ans);
}
}
hdu 1937 Finding Seats的更多相关文章
- HDU 1937 F - Finding Seats 枚举
F - Finding Seats Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- hdu1937 Finding Seats
hdu1937 Finding Seats 题意是 求最小的矩形覆盖面积内包含 k 个 空位置 枚举上下边界然后 双端队列 求 最小面积 #include <iostream> #incl ...
- hdu 4414 Finding crosses【简单模拟】
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4414 CSUST:点击打开链接 Finding crosses Time Limit: 2000/1000 ...
- hdu 4414 Finding crosses
题目链接:hdu 4414 其实是一道简单的字符型水题,不涉及任何算法,可比赛时却没能做出来,这几天的状态都差到家了... 题目大意是求有多少个满足条件的十字架,十字架的边不能有分叉路口,所以枚举每个 ...
- HDU 4668 Finding string (解析字符串 + KMP)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题意:给出一个压缩后的串,以及一个模式串,问模式串 ...
- HDU 1937 J - Justice League
J - Justice League Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- HDU 4414 Finding crosses (DFS + BFS)
题意:在N*N的图中,找出孤立存在的十字架的个数.十字架要求为正十字,孤立表示组成十字架的‘#的周围的一格再无’#‘. dfs找出在中心的‘#’(周围四格也为‘#'),则缩小了搜索范围,再bfs找出是 ...
- UVa 11846 - Finding Seats Again
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- HDU 5992 Finding Hotels(KD树)题解
题意:n家旅店,每个旅店都有坐标x,y,每晚价钱z,m个客人,坐标x,y,钱c,问你每个客人最近且能住进去(非花最少钱)的旅店,一样近的选排名靠前的. 思路:KD树模板题 代码: #include&l ...
随机推荐
- 深度学习2--安装opencv3.1
1\opencv的安装参考视频 2\ 以下内容来自:http://blog.csdn.net/l18930738887/article/details/54696148 本人因为被坑过,所以建议各位最 ...
- focus + select
focus使光标定位到目标节点之后 select选中光标所在位置的全部内容
- javaweb学习纲要
Java Web 概述 大纲: 1.C/S体系结构 2.B/S体系机构 3.两种体系结构比较 4.主流的Web程序应用平台 5.java web学习路线图 1.C/S体系结构 C/S是Client/ ...
- Linux Shell基础 环境变量
环境变量 环境变量和用户自定义变量最主要的区别在于,环境变量是全局变量,而用户自定义变量是局部变量.用户自定义变量只在当前的 Shell 中生效,而环境变量会在当前 Shell 和这个 Shell 的 ...
- Python编程-网络编程进阶(IO复用、Socketserver)
一.认证客户端的链接合法性 如果你想在分布式系统中实现一个简单的客户端链接认证功能,又不像SSL那么复杂,那么利用hmac+加盐的方式来实现. 服务端 from socket import * imp ...
- Go reflect反射
Go语言中的反射非常强大,可以对string, int, struct, func...进行反射,使用起来也比较简单. 示例1:反射函数 package main import ( "fmt ...
- vRA7 Software Component
将自定义Property传递给Software Component 示例: vRA7 支持 Software Components,并且还可以在用户的申请页面中,做一个下拉菜单,让用户选择需要安装的S ...
- iptables DNAT、SNAT和MASQUERATE
MASQUERADE 地址伪装,和SNAT功能一样,只不过SNAT使用固定IP地址,MASQUERADE使用网卡上的地址. SNAT配置: iptables -t nat -A POSTROUTING ...
- Java多线程的集合类
适用于多线程环境下的集合类: 1.阻塞队列:ArrayBlockingQueue(数组实现队列),LinkedBlockingQueue(链表实现队列) public class BlockingQu ...
- ZK服务管理中心
ZK基础类及服务的注册与发现: package top.letsgogo.util; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zk ...