POJ 2398 Toy Storage POJ2318提高版入门题
来源:互联网 发布:手机淘宝里输入链接 编辑:程序博客网 时间:2024/06/01 10:17
在poj 2318的基础上 加上一个排序(因为板的坐标不是有序的),再加多一个统计就好了。
View Code
#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;struct point{ int x, y;};struct node{ int up, down;}date[1007];int n, m;point toy[1007];point a, b;int ans[1007], cnt[1007];int cross(point o, point a, point b){ return ((a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x));}int find(point key){ int l , r, mid; l = 0; r = n+1; point upp, downn; upp.y = a.y; downn.y = b. y; while(l <= r) { mid = (l + r) >> 1; upp.x = date[mid].up; downn.x = date[mid].down; if(cross(downn, upp, key) > 0 ) r = mid - 1; else l = mid + 1; } return l;}bool cmp(node a, node b){ return a.up<b.up;}int main(){ int i, j; while( ~scanf("%d", &n) && n) { scanf("%d", &m); scanf("%d%d%d%d",&a.x, &a.y, &b.x, &b.y); date[0].up = date[0].down = a.x; date[n+1].up = date[n+1].down = b.x; for(i = 1; i <= n; i++) scanf("%d%d",&date[i].up, &date[i].down); sort(date+1, date+n+1, cmp); memset(ans, 0, sizeof(ans)); memset(cnt, 0, sizeof(cnt)); for(i=1;i<=m;i++) { scanf("%d%d", &toy[i].x, &toy[i].y); int index = find(toy[i]); ans[index-1]++; } printf("Box\n"); for(i=0;i<=n;i++) if(ans[i])cnt[ans[i]]++; for(i=0;i<=n;i++) if(cnt[i])printf("%d: %d\n",i, cnt[i]); } return 0;}
- POJ 2398 Toy Storage POJ2318提高版入门题
- poj 2398 Toy Storage
- poj 2398 Toy Storage
- POJ 2398 Toy Storage
- POJ 2398 Toy Storage
- poj 2398 toy storage
- poj 2398 Toy Storage
- POJ 2398 Toy Storage
- poj 2398Toy Storage
- POJ 2398 Toy Storage
- poj 2398 Toy Storage
- poj 2398 Toy Storage
- poj 2398 Toy Storage
- Poj-2398-Toy Storage
- poj 2398 Toy Storage
- poj 2398 Toy Storage
- poj 2398 Toy Storage
- Toy Storage(poj 2398)
- POJ 2923 Relocation 状态压缩DP + 0-1背包
- POJ 1155 TELE 树形DP(0-1背包)
- POJ 3093 Margaritas on the River Walk 0-1背包好题
- 【转】 POJ计算几何
- POJ 2318 TOYS 计算几何 入门题 叉积 + 二分
- POJ 2398 Toy Storage POJ2318提高版入门题
- POJ 3304 Segment 直线与线段相交 + 枚举
- POJ 1269 Intersecting Lines 判断直线关系(相交(求交点),重合,平行)
- Senparc.Weixin.MP SDK 微信公众平台开发教程(三):微信公众平台开发验证
- jquery对象和DOM对象的相互转换
- POJ 1556 The Doors 最短路floyd + 判断两线段相交
- POJ 2653 Pick-up sticks 枚举 + 判断两线段规范相交
- oracle 查询语句后面的where条件为null就不需要
- POJ 1066 Treasure Hunt 判断两线段是否相交