TOYS
TOYS
Calculate the number of toys that land in each bin of a partitioned toy box.
Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They gave John a rectangular box to put his toys in, but John 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 John to find his favorite toys.
John's parents came up with the following idea. They put cardboard partitions into the box. Even if John keeps throwing his toys into the box, at least toys that get thrown into different bins stay separated. The following diagram shows a top view of an example toy box.
For this problem, you are asked to determine how many toys fall into each partition as John throws them into the toy box.
Input
Output
Sample Input
5 6 0 10 60 0 3 1 4 3 6 8 10 10 15 30 1 5 2 1 2 8 5 5 40 10 7 9 4 10 0 10 100 0 20 20 40 40 60 60 80 80 5 10 15 10 25 10 35 10 45 10 55 10 65 10 75 10 85 10 95 10 0
Sample Output
0: 2 1: 1 2: 1 3: 1 4: 0 5: 1 0: 2 1: 2 2: 2 3: 2 4: 2
Hint
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define LL long long
using namespace std;
];
],D[];
int read(){
,f=; char ch=getchar();
'){if (ch=='-') f=-f; ch=getchar();}
+ch-',ch=getchar();
return x*f;
}
int cross(int x_0,int y_0,int x_1,int y_1){
return x_0*y_1-x_1*y_0;
}
int main(){
n=read();
while (n){
m=read(),U[]=D[]=read(),uy=read(),U[n+]=D[n+]=read(),dy=read();
; i<=n; i++) U[i]=read(),D[i]=read();
memset(ans,,sizeof ans);
; i<=m; i++){
int x=read(),y=read();
,R=n+,mid,pos;
while (L<=R){
mid=(L+R)>>;
) R=mid-,pos=mid; ;
}
ans[pos-]++;
}
; i<=n; i++) printf("%d: %d\n",i,ans[i]);
putchar('\n');
n=read();
}
;
}
TOYS的更多相关文章
- 【POJ】2318 TOYS(计算几何基础+暴力)
http://poj.org/problem?id=2318 第一次完全是$O(n^2)$的暴力为什么被卡了-QAQ(一定是常数太大了...) 后来排序了下点然后单调搞了搞..(然而还是可以随便造出让 ...
- poj 2318 TOYS (二分+叉积)
http://poj.org/problem?id=2318 TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 101 ...
- POJ 2318 TOYS (计算几何,叉积判断)
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8661 Accepted: 4114 Description ...
- POJ 2318 TOYS && POJ 2398 Toy Storage(几何)
2318 TOYS 2398 Toy Storage 题意 : 给你n块板的坐标,m个玩具的具体坐标,2318中板是有序的,而2398无序需要自己排序,2318要求输出的是每个区间内的玩具数,而231 ...
- poj 2318 TOYS
TOYS 题意:给定一个如上的长方形箱子,中间有n条线段,将其分为n+1个区域,给定m个玩具的坐标,统计每个区域中的玩具个数. 思路:这道题很水,只是要知道会使用叉乘来表示点在线的上面还是下面: 当a ...
- 【POJ】2318 TOYS ——计算几何+二分
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10281 Accepted: 4924 Description ...
- Codeforces Round #346 (Div. 2) C Tanya and Toys
C. Tanya and Toys 题目链接http://codeforces.com/contest/659/problem/C Description In Berland recently a ...
- 2016NEFU集训第n+3场 G - Tanya and Toys
Description In Berland recently a new collection of toys went on sale. This collection consists of 1 ...
- POJ2318 TOYS(叉积判断点与直线的关系+二分)
Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a prob ...
- POJ2318 TOYS[叉积 二分]
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14433 Accepted: 6998 Description ...
随机推荐
- 批处理bat标准化获取当前系统日期的几种方法,补0
首先有两个推荐的方案. 一: for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get Loc ...
- Go 灵活多变的切片Slice
我们知道数组定义好之后其长度就无法再修改,但是,在实际开发过程中,有时候我们并不知道需要多大的数组,我们期望数组的长度是可变的, 在 Go 中有一种数据结构切片(Slice) 解决了这个问题,它是可变 ...
- 线性判别分析(Linear Discriminant Analysis-LDA)
Linear Discriminant Analysis(LDA线性判别分析) 用途:数据预处理中的降维,分类任务 目标:LDA关心的是能够最大化类间区分度的坐标轴成分,将特征空间(数据集中的多维样本 ...
- webpack插件配置(二)- HtmlWebpackPlugin
作用 简化Html文件的创建,以便为你的webpack bundle包提供服务.这对于在文件名中包含每次会随着编译而发生变化的hash的webpack bundle尤其有用.插件可以生成一个HTML文 ...
- Nginx教程---01.Nginx入门
create by 三七二十一 LZ参考视频(年代久远,但万变不离其宗): 链接:https://pan.baidu.com/s/1O_MmN0c3ckM6vbk08n8Qkg 密码:z9zr 01_ ...
- Winform 设置控件值
private void SetControlValue(Control control, object value) { try { control.FindForm().Invoke((Actio ...
- 【Python】【一些概念与对比】
type.__new__() : 返回类.可以把类看作是metaclass 创建出来的实例 普通类里的__new__() : 返回类的实例. __new__() : 返回类的实例.Python解释器 ...
- async函数对比Generator函数
首先定义一个读取文件的异步函数 var readFile = function(fileName){ return new Promise((resolve,reject)=>{ fs.read ...
- 在SQL Server 2018 Management Studio中修改表字段顺序
有时我们可能需要为一个已存在的数据库表添加字段,并且想让这个字段默认排的靠前一些,这时就需要为表字段重新进行排序,默认情况下在Management Studio中调整顺序并保存时会提示“不允许保存更改 ...
- HashMap源码解读
1.HashMap 1.6解读 a).put,get,遍历方式参看 http://www.cnblogs.com/skywang12345/p/3310835.html#a23 需要注意的是,1.7 ...