Toy Storage POJ - 2398(计算几何基础判断点与直线位置+二分)

YOLOv8中的DFL:如何通过概率分布提升目标检测精度 本文深入解析了YOLOv8中的DFL(Distribution Focal Loss)如何通过概率分布提升目标检测精度。通过对比传统回归方法与DFL的概率分布预测,详细拆解了其数学原理和工程实现细节,并提供了实战效果对比与调优建议,帮助开发者更好地应用这一技术提升检测性能。 阅读详情

Toy Storage POJ - 2398

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 0
20 20
80 80
60 60
40 40
5 10
15 10
95 10
25 10
65 10
75 10
35 10
45 10
55 10
85 10
5 6 0 10 60 0
4 3
15 30
3 1
6 8
10 10
2 1
2 8
1 5
5 5
40 10
7 9
0

Sample Output

Box
2: 5
Box
1: 4
2: 1

这道题和TOYS POJ - 2318同款
直接改一下输出即可

code:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 5100;
struct Point{
    int x,y;
    Point(){}
    Point(int xx,int yy):x(xx),y(yy){}
};
struct Card{
    Point up,down;
    Card(){}
    Card(int x1,int y1,int x2,int y2){
        up = Point(x1,y1);
        down = Point(x2,y2);
    }
    bool operator < (const Card &other)const{
        if(up.x == other.up.x)
            return down.x < other.down.x;
        return up.x < other.up.x;
    }
}c[maxn];
int n,m,x1,y1,x2,y2;
int pos[maxn];
bool judge(int x,int y,int mid){
    int ans = (c[mid].up.x-x) * (c[mid].down.y-y) - (c[mid].down.x-x) * (c[mid].up.y-y);
    if(ans < 0) return false;//在线左侧
    return true;//在线右侧
}
void search(int x,int y){
    int l = 0,r = n - 1;
    while(l <= r){
        int mid = l + r >> 1;
        if(judge(x,y,mid))
            l = mid + 1;
        else{
            r = mid - 1;
        }
    }
    pos[l]++;
}
int ans[maxn];
int main(){
    while(~scanf("%d",&n) && n){
        scanf("%d%d%d%d%d",&m,&x1,&y1,&x2,&y2); 
        for(int i = 0; i < n; i++){
            int u,l;
            scanf("%d%d",&u,&l);
            c[i] = Card(u,y1,l,y2);
        }
        sort(c,c+n);
        memset(pos,0,sizeof(pos));
        for(int i = 0; i < m; i++){
            int x,y;
            scanf("%d%d",&x,&y);
            search(x,y);
        }
        memset(ans,0,sizeof(ans));
        for(int i = 0; i <= n; i++){
            ans[pos[i]]++;
        }
        printf("Box\n");
        for(int i = 1; i <= m; i++){
            if(ans[i]) printf("%d: %d\n",i,ans[i]);
        }
    }
    return 0;
}
从身高预测到目标检测:DFL损失函数的实战应用指南 本文深入解析了YOLOv8中引入的DFL(Distribution Focal Loss)损失函数,通过“猜身高”的生动类比,阐明其将困难的连续值回归转化为离散分类问题的核心思想。文章详细阐述了DFL的工作原理、在YOLOv8中的代码实现、调试方法及其带来的精度提升与训练稳定性优势,为开发者提供了实用的实战应用指南。 阅读详情

相关推荐

【老生谈算法】可视化通道流中瞬时涡量场的算法实现与MATLAB源码分析——瞬时涡量场

本文旨在探讨可视化通道流中瞬时涡量场的方法,并通过MATLAB编程实现这一过程。涡量场作为描述流体旋涡强度和方向的重要物理量,对于理解复杂流体运动具有重要意义。本文首先介绍了涡量场的基本概念,随后详细阐述了从测量数据收集到涡量场可视化的完整流程,并给出了相应的MATLAB源码。通过实际运行该源码,我们展示了涡量场的可视化结果,并讨论了其在流动结构识别和动力学行为理解中的应用。关键词: 涡量场;流体运动;MATLAB;可视化;PIV一、引言。

m0_53407570的博客 1132

API服务调用权限体系构建:从开通授权到安全实践全解析

在微服务与云原生架构中,API(应用程序编程接口)作为系统间通信的核心枢纽,其安全调用机制是保障服务稳定与数据安全的基础。权限管理的核心原理在于通过身份认证与授权策略,精确控制调用方对API资源的访问范围,从而防止未授权访问与潜在攻击。这一机制的技术价值在于实现最小权限原则,降低安全风险,并提升系统的可维护性。在实际应用场景中,无论是集成第三方支付、短信服务,还是构建内部微服务网络,都需要建立清晰的权限模型。本文聚焦于**API服务开通**与**调用权限授予**这一关键流程,深入解析如何通过创建RAM用户、

weixin_30522095的博客 496

软件测试面试题汇总

软件测试面试题汇总 测试技术面试题 ........................................................................................................................................................................ 5 1、什么是兼容

晴天的专栏 2万+

计算几何——Toy Storage(叉积)

原文链接:poj.org/problem?id=2398 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. Unfort...

mumei的博客 302

CosyVoice 本地部署详细教程 手把手小白教程

本文提供了详细的CosyVoice本地部署教程,强调了避免中文名称和空格的重要性,并列出了必要的软件安装步骤,包括CUDA、cuDNN、Git和Miniconda。教程涵盖了从检查CUDA版本到下载模型和运行模型的全过程,确保用户能够顺利部署并使用CosyVoice。

huazn612的博客 2万+

从触觉到视觉:GelSight传感器的工作原理与实战应用指南

本文深入解析了GelSight光学触觉传感器的核心工作原理,它通过将物理接触转化为视觉图像,为机器人提供了高精度的触觉感知。文章详细介绍了其在工业微观缺陷检测、机器人灵巧操作等领域的实战应用,并提供了从系统搭建到算法开发的完整指南,帮助工程师将这一前沿技术落地于实际项目。

solidity8miner的博客 963

POJ2398 Toy Storage

简直和2318一模一样,唯一的区别就是得排序,和输出的是统计的数据。 方法还是一样二分+叉积 Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2491   Accepted: 1427 Description Mom and dad have

765

【系统分析师】第6章-基础知识:企业信息化(核心总结)

企业信息化是数字化转型的核心,涵盖战略规划、技术应用和实施路径等方面。关键内容包括ERP、CRM、SCM等系统的定义与实施,以及数据仓库、商业智能等技术的应用。备考系统分析师需掌握信息化战略规划方法(如BSP、SDP)、系统建模工具,并能分析解决信息孤岛等问题。论文可围绕ERP实施、数据仓库应用等主题展开。企业信息化面临组织变革、技术选型等挑战,但能显著提升运营效率和竞争力。

数据知道的博客 6950

Toy Storage POJ - 2398

题目链接:Toy Storage 思路 这个题和上个题做法一致,只是输出变了,而且加个排序。 点与直线的位置关系 //`点和直线关系` //`1 在左侧` //`2 在右侧` //`3 在直线上` int relation(Point p) { int c = sgn((p - s) ^ (e - s)); if (c < 0)return 1; else if (c > 0)return 2; else return 3; } 主函数 int n,m; in

AAmiu的博客 193

MuJoCo 入门教程(四)建模

在 MJCF 中,一个体可以包含多个关节,因此无需引入虚拟体来创建复合关节。相反,只需在同一主体中定义构成所需复合关节的所有原始关节即可。例如,可以使用两个滑块和一个铰链来模拟在平面内运动的肢体。其他 MJCF 元素可以在嵌套的主体元素所创建的树中定义,特别是关节、几何体、场地、摄像机、灯光。当一个元素被定义在一个肢体内时,它就固定在该肢体的局部坐标系上,并始终随其移动。涉及多个机构或根本不涉及机构的元素,将在运动树之外的单独部分中定义。

机器人控制与仿真应用 4181

Python 爬虫实战:微博自动化运营工具(点赞 / 转发 / 评论 + 反封号策略)

微博作为中国最大的社交媒体平台之一,拥有庞大的用户群体和丰富的数据资源。通过 Python 爬虫技术,我们可以实现微博的自动化运营,包括点赞、转发、评论等功能,同时采取有效的反封号策略,确保账号的安全和稳定运行。

u014481728的博客 1187

POJ_2318_TOYS&&POJ_2398_Toy Storage_二分+判断直线和点的位置关系

POJ_2318_TOYS&&POJ_2398_Toy Storage_二分+判断直线和点的位置 Description Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John n...

118

【AHE数据集】中国2019年多源热排放数据集-500m空间分辨率

【AHE数据集】中国2019年多源热排放数据集

WW、forever的博客 419

POJ2318 TOYS 和POJ2398 Toy Storage题解(点在四边形内)(简单几何)

POJ 2318 TOYS 链接:http://poj.org/problem?id=2318 POJ 2398 Toy Storage 链接:http://poj.org/problem?id=2398 poj2318题目大意:给你一个盒子的俯视图,从左到右将每个格子划分为0,1,2...n;给你一些点的坐标,让你输出每个格子里点的个数。 poj2398题目大意:给你一个盒子的俯视

若世界是黑暗,那我便是黎明。 弱者为何而战!? 540

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

poj2398Toy Storage【判断直线与点位置关系+排序+二分查找】

Language: Default Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4633   Accepted: 2741 Description Mom and dad have a problem: their child, Reza

走一步再走一步 585

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

POJ -2398 Toy Storage(差积判断点与直线位置)

Toy Storage Time Limit: 1000MS Memory Limit: 65536K 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 r...

名字太长容易被发现并打死 210

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

poj 2398 Toy Storage(计算几何,点跟直线的位置关系)

这个题是poj 2318 的变形  链接poj 2318 主要就是告诉你的划分的线段的顺序不是有序的了。然后再输出要求上要求输出的是有m个玩具的箱子的个数。 主要思路不变,只要把line数组里的直线排个序,跟2318一样的做法AC。 具体实现看代码。 #include #include #include #include using namespace std; const int M

多啦A梦也会有好多的烦恼 1003

POJ 2398 Toy Storage

Toy Storage Time Limit: 1000MS Memory Limit: 65536K 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 rectang...

忘梦心的博客 242

poj 2398 Toy Storage 计算几何+二分

poj 2398 Toy Storage 计算几何+二分 Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5296 Accepted: 3136 Description Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave R

klc的博客 343

POJ2318 TOYS + 2398 Toy Storage

二分+叉积 http://poj.org/problem?id=2318 http://poj.org/problem?id=2398 //2318#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath&...

weixin_30376453的博客 113

初入计算几何——[poj_2318] TOYS && [poj_2398]Toy Storage

TOYS 题目意思就是给你一个盒子,然后用几条线把盒子分块,然后告诉你玩具的坐标,问你每一块中有多少个玩具。 主要算法就是判断点在直线的两侧,可以用叉积来看。 在直线上取两点AAA,BBB,(这题可以直接取端点),要判断的点为CCC点, 根据右手准则就可以判断出,所以点在线段左侧时,叉积小于0;在右侧时,叉积大于0。 这题只要找到第一个叉积小于0的就行。 #include<algorithm> #include<cstdio> #include<cstring> #in

xyq的博客 250

poj-2398 Toy Storage (排序+叉积)

Toy Storage  POJ - 2398  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. Unfortuna...

qq_38182397的博客 324

POJ 2398 Toy Storage(叉积+二分)

题目链接:点击打开链接

RaynX的专栏 720

【POJ-2398-Toy Storage】判断点与直线的关系

POJ-2398-Toy Storage 题意 用n条直线分成将一个长方形分成n+1个区域,给你m个点,统计每个区域内点的个数 1&amp;lt;=n,m&amp;lt;=1e31&amp;lt;=n,m&amp;lt;=1e31&lt;=n,m&lt;=1e3 做法 我们可以按照n条直线与上界的交点对n条直线排序,之后暴力扫描看他在哪个区域即可。 代码 #include &lt;stdio.h&...

lajiyuan的博客 386

POJ 2398 Toy Storage(点和向量位置关系/二分)

题目链接 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 rebellio...

Happig的博客 171

[POJ2398]Toy Storage(计算几何,二分,判断点在线段的哪一侧)

题目链接:http://poj.org/problem?id=2398 思路RT,和POJ2318一样,就是需要排序,输出也不一样。手工画一下就明白了。注意叉乘的时候a×b是判断a在b的顺时针还是逆时针侧,>0是顺时针测,<0是逆时针侧,本题对应看成右、左侧,特别注意。 1 /* 2 ━━━━━┒ギリギリ♂ eye! 3 ┓┏┓┏┓┃キリキリ♂ mind! ...

weixin_30376323的博客 128
上一篇: TOYS POJ - 2318(计算几何判断点和直线位置+二分)
下一篇: Segments POJ - 3304(计算几何基础判断两直线相交)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址