HDU3622 Bomb Game

本文介绍了一种结合二分查找与2-SAT算法解决特定炸弹放置游戏的最优策略问题。游戏中玩家需选择每轮出现的两个点之一放置炸弹,并确保各炸弹爆炸范围不重叠,以最大化最小爆炸半径。

Bomb Game


Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3703 Accepted Submission(s): 1279


Problem Description
Robbie is playing an interesting computer game. The game field is an unbounded 2-dimensional region. There are N rounds in the game. At each round, the computer will give Robbie two places, and Robbie should choose one of them to put a bomb. The explosion area of the bomb is a circle whose center is just the chosen place. Robbie can control the power of the bomb, that is, he can control the radius of each circle. A strange requirement is that there should be no common area for any two circles. The final score is the minimum radius of all the N circles.
Robbie has cracked the game, and he has known all the candidate places of each round before the game starts. Now he wants to know the maximum score he can get with the optimal strategy.


Input
The first line of each test case is an integer N (2 <= N <= 100), indicating the number of rounds. Then N lines follow. The i-th line contains four integers x1i, y1i, x2i, y2i, indicating that the coordinates of the two candidate places of the i-th round are (x1i, y1i) and (x2i, y2i). All the coordinates are in the range [-10000, 10000].


Output
Output one float number for each test case, indicating the best possible score. The result should be rounded to two decimal places.


Sample Input
2
1 1 1 -1
-1 -1 -1 1
2
1 1 -1 -1
1 -1 -1 1


Sample Output
1.41
1.00


Source
2010 Asia Regional Tianjin Site —— Online Contest

题意:有n对炸弹,你只能从每对里选出一个每一个都有个坐标,要求求出这些炸弹的爆炸范围的最大值(爆炸范围不能和其他炸弹相交)。

每对中只能选一个,很容易想到2-SAT,然后求出最大,又想到了二分。。这题就是二分加2-SAT。

枚举两个点之间的距离(除以2就是答案),如果两个炸弹之间的距离比这个还小说明这两个不能同时爆炸(就是这两个中只能选一个),我把每对炸弹分成了左边一个右边一个,i<<1表示选第i对中左边的,i<<1|1表示选第i对中右边的,然后按上面的思想枚举点建图,然后tarjan判下符不符合就可以了。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;
const int MAXN=210;
const int MAXE=40010;
int head[MAXN],size;
struct EDGE
{
    int v,next;
}edge[MAXE];
int sccno[MAXN],pre[MAXN],low[MAXN],dfs_clock,sc_cnt;
stack<int> S;
void init()
{
    memset(sccno,0,sizeof(sccno));
    memset(pre,0,sizeof(pre));
    memset(head,-1,sizeof(head));
    dfs_clock=sc_cnt=size=0;
}
void add_edge(int u,int v)
{
    edge[size].v=v;
    edge[size].next=head[u];
    head[u]=size++;
}
void tarjan(int u)
{
    pre[u]=low[u]=++dfs_clock;
    S.push(u);
    for(int i=head[u];i!=-1;i=edge[i].next)
    {
        int v=edge[i].v;
        if(!pre[v])
        {
            tarjan(v);
            low[u]=min(low[u],low[v]);
        }
        else if(!sccno[v])
        {
            low[u]=min(low[u],pre[v]);
        }
    }
    if(low[u]==pre[u])
    {
        sc_cnt++;
        while(1)
        {
            int x=S.top();
            S.pop();
            sccno[x]=sc_cnt;
            if(u==x)
                break;
        }
    }
}
double dist(int x1,int y1,int x2,int y2)
{
    return (double)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int lx[110],ly[110],rx[110],ry[110],n;
void build(double mid)
{
    init();
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
                continue;
            if(dist(lx[i],ly[i],lx[j],ly[j])<mid)
            {
                add_edge(i<<1,j<<1|1);
                add_edge(j<<1,i<<1|1);
            }
            if(dist(rx[i],ry[i],rx[j],ry[j])<mid)
            {
                add_edge(i<<1|1,j<<1);
                add_edge(j<<1|1,i<<1);
            }
            if(dist(lx[i],ly[i],rx[j],ry[j])<mid)
            {
                add_edge(i<<1,j<<1);
                add_edge(j<<1|1,i<<1|1);
            }
            if(dist(rx[i],ry[i],lx[j],ly[j])<mid)
            {
                add_edge(i<<1|1,j<<1|1);
                add_edge(j<<1,i<<1);
            }
        }
    }
}
bool test()
{
    for(int i=0;i<2*n;i++)
        if(!pre[i])
        tarjan(i);
    for(int i=0;i<n;i++)
    {
        if(sccno[i<<1]==sccno[i<<1|1])
            return 0;
    }
    return 1;
}
int main()
{
    int i;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<n;i++)
        {
            scanf("%d%d%d%d",&lx[i],&ly[i],&rx[i],&ry[i]);
        }
        double l=0,r=10000;
        double ans=0;
        while(r-l>=1e-4)
        {
            double mid=(l+r)/2;
            build(mid*mid);
            if(test())
            {
                ans=mid;
                l=mid;
            }
            else
                r=mid;
        }
        printf("%.2f\n",ans/2);
    }
    return 0;
}


植物实例分割数据集 一、基础信息 数据集名称:植物实例分割数据集 图片数量: - 训练集:9,600张图片 - 验证集:913张图片 - 测试集:455张图片 总计:10,968张图片 分类类别:59个类别,对应数字标签0至58,涵盖多种植物状态或特征。 标注格式:YOLO格式,适用于实例分割任务,包含多边形标注点。 数据格式:图像文件,来源于植物图像数据库,适用于计算机视觉任务。 二、适用场景 • 农业植物监测AI系统开发:数据集支持实例分割任务,帮助构建能够自动识别植物特定区域并分类的AI模型,辅助农业专家进行精准监测和分析。 • 智能农业应用研发:集成至农业管理平台,提供实时植物状态识别功能,为作物健康管理和优化种植提供数据支持。 • 学术研究与农业创新:支持植物科学与人工智能交叉领域的研究,助力发表高水平农业AI论文。 • 农业教育与培训:数据集可用于农业院校或培训机构,作为学生学习植物图像分析和实例分割技术的重要资源。 三、数据集优势 • 精准标注与多样性:标注采用YOLO格式,确保分割区域定位精确;包含59个类别,覆盖多种植物状态,具有高度多样性。 • 数据量丰富:拥有超过10,000张图像,大规模数据支持模型充分学习和泛化。 • 任务适配性强:标注兼容主流深度学习框架(如YOLO、Mask R-CNN等),可直接用于实例分割任务,并可能扩展到目标检测或分类等任务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值