POJ2014 Flow Layout
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 3161 | Accepted: 2199 |
Description
For example, given a window that can be at most 35 units wide, and three rectangles with dimensions 10 x 5, 20 x 12, and 8 x 13, the flow layout manager would create a window that looked like the figures below after each rectangle was added.
The final dimensions of the resulting window are 30 x 25, since the width of the first row is 10+20 = 30 and the combined height of the first and second rows is 12+13 = 25.
Input
Output
Sample Input
35
10 5
20 12
8 13
-1 -1
25
10 5
20 13
3 12
-1 -1
15
5 17
5 17
5 17
7 9
7 20
2 10
-1 -1
0
Sample Output
30 x 25
23 x 18
15 x 47
Source
纯模拟。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define LL long long
using namespace std;
const int mxn=;
int read(){
int x=,f=;char ch=getchar();
while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int limit=;
int now=;
int w=;
int h=;
int last=;
int main(){
int x,y;
while(){
limit=read();
if(!limit)break;
w=h=last=now=;
while(){
x=read();y=read();
if(x==- && y==-){
printf("%d x %d\n",w,h);
break;
}
if(now+x<=limit){
now+=x;
w=max(w,now);
h=max(h,last+y);
}
else{
now=x;
w=max(now,w);
last=h;
h=last+y;
}
// printf("now: %d %d\n",w,h);
}
}
return ;
}
POJ2014 Flow Layout的更多相关文章
- Flow Layout
--------------siwuxie095 将根面板 contentPane 的布局切换为 Flow Layout Flow La ...
- Collection View Programming Guide for iOS---(四)---Using the Flow Layout
Using the Flow Layout使用流布局 The UICollectionViewFlowLayout class is a concrete layout object that y ...
- POJ 2014:Flow Layout 模拟水题
Flow Layout Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3091 Accepted: 2148 Descr ...
- Collection View 自定义布局(custom flow layout)
Collection view自定义布局 一般我们自定义布局都会新建一个类,继承自UICollectionViewFlowLayout,然后重写几个方法: prepareLayout():当准备开始布 ...
- POJ 2014 Flow Layout 模拟
http://poj.org/problem?id=2014 嘻嘻2014要到啦,于是去做Prob.ID 为2014的题~~~~祝大家新年快乐~~ 题目大意: 给你一个最大宽度的矩形,要求把小矩形排放 ...
- Flutter 布局(九)- Flow、Table、Wrap详解
本文主要介绍Flutter布局中的Flow.Table.Wrap控件,详细介绍了其布局行为以及使用场景,并对源码进行了分析. 1. Flow A widget that implements the ...
- Border Layout
------------------siwuxie095 根面板 contentPane 的默认布局就是 Border Layout B ...
- 细说Java主流日志工具库
概述 在项目开发中,为了跟踪代码的运行情况,常常要使用日志来记录信息. 在Java世界,有很多的日志工具库来实现日志功能,避免了我们重复造轮子. 我们先来逐一了解一下主流日志工具. java.util ...
- iOS6新特征:UICollectionView介绍
http://blog.csdn.net/eqera/article/details/8134986 1.1. Collection View 全家福: UICollectionView, UITab ...
随机推荐
- [转]Android TCP长连接 心跳机制及实现
背景知识 智能手机上的长连接心跳和在Internet上的长连接心跳有什么不同 Android系统的推送和iOS的推送有什么区别 几种推送的实现方式 协议 1XMPP简介 2 MQTT简介 3移动端消息 ...
- Thymeleaf 在项目中的应用及前后端交互的一些知识(1)
经过一段时间的工作,我的第一个项目已经快要上线了.本篇文章介绍些thymeleaf在工作中的实际应用,但是更多的还是一些前端处理后台数据的一些思路,如果有什么不正确的地方,希望大家指点. 1.th:e ...
- logging模块基础
很多程序都有记录日志的需求,日志不仅可以保存访问记录,也可以有错误,警告等信息输出. python的logging模块提供了标准的日志接口,可以通过logging存储各种格式的日志.logging模块 ...
- 离开APM的弹性云还是真弹性吗
准确来说应该叫脱离业务的弹性云或者容器都是伪弹性.之所以标题中有APM一是因为它近来热门,二是因为它在我将要说的这个事情上起到关键性的作用. 不管是亚马逊的弹性云.容器方案或者国内众多云厂商在自动伸缩 ...
- win应用只允许单个实例运行,并将已运行实例窗口置顶
关键词:windows,c++,桌面应用,单个实例,窗口置顶 目标:1.判断本程序是否已有一个实例在运行.2.若有,则激活已在运行的实例(将其窗口置顶),并退出当前运行. 1.使用semaphore来 ...
- java读取大文件 超大文件的几种方法
java 读取一个巨大的文本文件既能保证内存不溢出又能保证性能 import java.io.BufferedReader; import java.io.File; import jav ...
- leetcode_1039. Minimum Score Triangulation of Polygon_动态规划
https://leetcode.com/problems/minimum-score-triangulation-of-polygon/ 题意:给定一个凸的N边形(N<=50),每个顶点有一个 ...
- diff - 找出两个文件的不同点
总览 diff [选项] 源文件 目标文件 描述 在最简单的情况是, diff 比较两个文件的内容 (源文件 和 目标文件). 文件名可以是 - 由标准输入设备读入的文本. 作为特别的情况是, dif ...
- JS将时间戳转换为刚刚、N分钟前、今天几点几分、昨天几点几分等表示法
使用Javascript语言,将时间戳转换为类似新浪微博的时间的表示方法. 要求转换规则: 1分钟以内显示为:刚刚 1小时以内显示为:N分钟前 当天以内显示为:今天 N点N分(如:今天 22:33) ...
- java_日期和时间
1.System类中的currentTimeMillis:1970年1.1到现在的毫秒数 public class DateTest { public static void main(String[ ...