D - Area of Mushroom

本文解析了一个关于无限区域管辖的问题,n个人分布在平面上的不同位置,每个人有自己的速度。文章探讨了如何判断每个人是否能管辖无限区域,并给出了具体的算法实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Teacher Mai has a kingdom with the infinite area.

He has n students guarding the kingdom.

The i-th student stands at the position (x i,y i), and his walking speed is v i.

If a point can be reached by a student, and the time this student walking to this point is strictly less than other students, this point is in the charge of this student.

For every student, Teacher Mai wants to know if the area in the charge of him is infinite.

Input

There are multiple test cases, terminated by a line "0".

For each test case, the first line contains one integer n(1<=n<=500).

In following n lines, each line contains three integers x i,y i,v i(0<=|x i|,|y i|,v i<=10^4).

Output

For each case, output "Case #k: s", where k is the case number counting from 1, and s is a string consisting of n character. If the area in the charge of the i-th student isn't infinite, the i-th character is "0", else it's "1".

Sample Input

3
0 0 3
1 1 2
2 2 1
0

Sample Output

Case #1: 100

题意是有n个人,每个人有一个坐标和速度,平面上如果的点如果他到达的时间严格的比其他任何人都快,那么这个点就属于他管辖。问每个人的管辖区域是不是无穷大。显然对于两个速度不同的人,速度小的人就不可能是无穷大。所以只需要找出速度最大的所有的人。先求出凸包,凸包的顶点是无穷大,然后找到所有凸包边上的点,这些点也可能是无穷大。然后暴力枚举所有的速度最大的点,如果和目前认为是无穷大的点重合,显然这两个重合点有相同速度到任何的点都是一样的时间,所以去掉。坑点是速度是0的点不可能无穷大。

wa了半天,我就是喜欢写代码bug

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iomanip>
#include<cmath>
#include<float.h> 
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define mm(x,b) memset((x),(b),sizeof(x))
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
typedef long long ll;
typedef long double ld;
typedef double db;
const ll mod=1e9+100;
const db e=exp(1);
const db eps=1e-8;
using namespace std;
const double pi=acos(-1.0);
const int INF=0xfffffff;
struct Point{
    int x,y,num,temp1,temp2;
}p[1007],s[1007],a[1007];
int direction(Point p1,Point p2,Point p3) 
{ 
    return (p3.x-p1.x)*(p2.y-p1.y)-(p2.x-p1.x)*(p3.y-p1.y); 
}//点2和3,按哪个和点一的角度更小排,相同的话按哪个更近排 
double dis(Point p1,Point p2) { return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y)); }
bool cmp(Point p1,Point p2)//极角排序 
{
    int temp=direction(p[0],p1,p2);
    if(temp<0)return true ;
    if(temp==0&&dis(p[0],p1)<dis(p[0],p2))return true;
    return false;
}
int Graham(int n)
{
    int top;
    int pos,minx,miny;
    minx=miny=INF;
    for(int i=0;i<n;i++)//找最下面的基点
        if(p[i].y<miny||(p[i].y==miny&&p[i].x<minx))
        {
            minx=p[i].x;
            miny=p[i].y;
            pos=i;
        }
    swap(p[0],p[pos]);
    sort(p+1,p+n,cmp);
    p[n]=p[0];
    s[0]=p[0];s[1]=p[1];s[2]=p[2];
    top=2;
    for(int i=3;i<=n;i++)
    {
        while(direction(s[top-1],s[top],p[i])>=0&&top>=2)top--;
        s[++top]=p[i] ;
    }
    return top;
}
int main()
{
    int n,ans=1;
    while(1)
    {
        sf("%d",&n);
        if(!n) return 0;
        int Max=0;
        rep(i,0,n)
        {
            a[i].temp1=0;a[i].temp2=0;
            sf("%d%d%d",&a[i].x,&a[i].y,&a[i].num);
            Max=max(Max,a[i].num);
        }
        if(Max==0)
        {
            pf("Case #%d: ",ans++);
            rep(i,0,n) 
            pf("0");
            pf("\n");
            continue;
        }
        rep(i,0,n) if(a[i].num==Max) a[i].temp1=1;
        rep(i,0,n)
        {
            if(a[i].num==Max)
            rep(j,0,n)
            {
                if(i!=j&&a[j].num==Max&&a[i].x==a[j].x&&a[i].y==a[j].y)
                {
                    a[i].temp1=0;a[j].temp1=0;
                }
            }
        } 
        int sum=0;
        rep(i,0,n)
        {
            if(a[i].num==Max)
            {
                int temp=0;
                rep(j,0,sum)
                    if(a[i].x==p[j].x&&a[i].y==p[j].y)
                        temp=1;
                if(temp==0)
                    p[sum++]=a[i];
            }
        }
        int top;
        top=Graham(sum);
        rep(i,0,top)
        {
            rep(j,0,n)
            {
                if(s[i].x==a[j].x&&s[i].y==a[j].y)
                a[j].temp2=1;
                if(direction(s[i],s[(i+1)%top],a[j])==0)
                a[j].temp2=1;
            }
        }
        pf("Case #%d: ",ans++);
        rep(i,0,n)
        if(a[i].temp1&&a[i].temp2)
        pf("1");
        else
        pf("0");
        pf("\n");
    }
}

转载于:https://www.cnblogs.com/wzl19981116/p/9419783.html

内容概要:本文详细介绍了施耐德M580系列PLC的存储结构、系统硬件架构、上电写入程序及CPU冗余特性。在存储结构方面,涵盖拓扑寻址、Device DDT远程寻址以及寄存器寻址三种方式,详细解释了不同类型的寻址方法及其应用场景。系统硬件架构部分,阐述了最小系统的构建要素,包括CPU、机架和模块的选择与配置,并介绍了常见的系统拓扑结构,如简单的机架间拓扑和远程子站以太网菊花链等。上电写入程序环节,说明了通过USB和以太网两种接口进行程序下载的具体步骤,特别是针对初次下载时IP地址的设置方法。最后,CPU冗余部分重点描述了热备功能的实现机制,包括IP通讯地址配置和热备拓扑结构。 适合人群:从事工业自动化领域工作的技术人员,特别是对PLC编程及系统集成有一定了解的工程师。 使用场景及目标:①帮助工程师理解施耐德M580系列PLC的寻址机制,以便更好地进行模块配置和编程;②指导工程师完成最小系统的搭建,优化系统拓扑结构的设计;③提供详细的上电写入程序指南,确保程序下载顺利进行;④解释CPU冗余的实现方式,提高系统的稳定性和可靠性。 其他说明:文中还涉及一些特殊模块的功能介绍,如定时器事件和Modbus串口通讯模块,这些内容有助于用户深入了解M580系列PLC的高级应用。此外,附录部分提供了远程子站和热备冗余系统的实物图片,便于用户直观理解相关概念。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值