博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2398 Toy Storage
阅读量:5241 次
发布时间:2019-06-14

本文共 3664 字,大约阅读时间需要 12 分钟。

Toy Storage
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6094   Accepted: 3639

Description

Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebellious and obeys his parents by simply throwing his toys into the box. All the toys get mixed up, and it is impossible for Reza to find his favorite toys anymore.
Reza's parents came up with the following idea. They put cardboard partitions into the box. Even if Reza keeps throwing his toys into the box, at least toys that get thrown into different partitions stay separate. The box looks like this from the top:
We want for each positive integer t, such that there exists a partition with t toys, determine how many partitions have t, toys.

Input

The input consists of a number of cases. The first line consists of six integers n, m, x1, y1, x2, y2. The number of cardboards to form the partitions is n (0 < n <= 1000) and the number of toys is given in m (0 < m <= 1000). The coordinates of the upper-left corner and the lower-right corner of the box are (x1, y1) and (x2, y2), respectively. The following n lines each consists of two integers Ui Li, indicating that the ends of the ith cardboard is at the coordinates (Ui, y1) and (Li, y2). You may assume that the cardboards do not intersect with each other. The next m lines each consists of two integers Xi Yi specifying where the ith toy has landed in the box. You may assume that no toy will land on a cardboard.
A line consisting of a single 0 terminates the input.

Output

For each box, first provide a header stating "Box" on a line of its own. After that, there will be one line of output per count (t > 0) of toys in a partition. The value t will be followed by a colon and a space, followed the number of partitions containing t toys. Output will be sorted in ascending order of t for each box.

Sample Input

4 10 0 10 100 020 2080 8060 6040 405 1015 1095 1025 1065 1075 1035 1045 1055 1085 105 6 0 10 60 04 315 303 16 810 102 12 81 55 540 107 90

Sample Output

Box2: 5Box1: 42: 1

Source

 
题意:这个题和2318的题意差不多,这个题只让你把有玩具的格子输出,然后按照排序输出就行了,但这个包括没有落在盒子里的玩具(好像包括,有点忘了,做的太久了)
 
题解:与poj 2318一样,按照题目意思进行模拟,仍然二分位置,找到压栈,然后排序输出
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define zero(a) fabs(a)
(y)) ? (x) : (y) )#define min( x, y ) ( ((x) < (y)) ? (x) : (y) )#define lowbit(x) (x&(-x))typedef long long ll;const double pi=acos(-1.0);const int inf=0x3f3f3f3f;const ll linf=0x3f3f3f3f3f3f3f3f;const int maxn = 5050;const double eps=1e-8;using namespace std;struct point{ int x,y; point() {} point(int _x,int _y) { x = _x; y = _y; } point operator -(const point &b)const { return point(x - b.x,y - b.y); }//叉积 double operator ^(const point &b)const { return x*b.y - y*b.x; }//点积 double operator *(const point &b)const { return x*b.x + y*b.y; }//绕原点旋转角度B(弧度值),后x,y的变化 void transXY(double B) { double tx = x,ty = y; x = tx*cos(B) - ty*sin(B); y = tx*sin(B) + ty*cos(B); }};struct Line{ point s,e; Line() {} Line(point _s,point _e) { s = _s; e = _e; }};Line line[maxn];//int ans[maxn];struct qw{ int num,id;} ans[maxn];int xmult(point p0,point p1,point p2){ return (p1-p0)^(p2-p0);}bool cmp1(Line a,Line b){ return a.s.x < b.s.x;}int cmp(qw x,qw y){ return x.num>y.num;}int main(){ int n,m,x1,y1,x2,y2; while(~scanf("%d",&n)&&n) { scanf("%d%d%d%d%d",&m,&x1,&y1,&x2,&y2); for(int i=0;i

 

转载于:https://www.cnblogs.com/lalalatianlalu/p/7672631.html

你可能感兴趣的文章
Python测试字符串是否为数字
查看>>
拓扑排序
查看>>
Open Associated Perspective?
查看>>
oracle字符集设置
查看>>
Java页面中文编码要转换两次encodeURI
查看>>
C# Image和Byte[]互相转换
查看>>
Jmeter组件认识
查看>>
C#反射(转载)
查看>>
SQL 课程
查看>>
排序算法
查看>>
url的反向解析
查看>>
如何成为一名优秀的前端工程师
查看>>
《TCP-IP详解卷1》中BGP部分的笔记
查看>>
安装Xamarin.Android几个经典介面
查看>>
03-树1 树的同构
查看>>
标准C程序设计七---101
查看>>
GDB实战
查看>>
内存探究记录
查看>>
6. Find Peak Element
查看>>
Excel 导出 按钮
查看>>