Home Database Mysql Tutorial HDU 3622 Bomb Game(2

HDU 3622 Bomb Game(2

Jun 07, 2016 pm 03:48 PM
game

HDU 3622 Bomb Game(2-SAT二分) http://acm.hdu.edu.cn/showproblem.php?pid=3622 题意: 有N对地点,每对地点中的一个地方要放一个*,你可以控制*的爆炸半径,现在要求所有N个被放的*爆炸范围不重叠.问你在所有可行方案中的*爆炸最大半径是多少?(假

HDU 3622 Bomb Game(2-SAT+二分)

http://acm.hdu.edu.cn/showproblem.php?pid=3622

题意:

        有N对地点,每对地点中的一个地方要放一个*,你可以控制*的爆炸半径,现在要求所有N个被放的*爆炸范围不重叠.问你在所有可行方案中的*爆炸最大半径是多少?(假设所有*爆炸半径相同,本假设与原提议的要求等价,可以自己想想)

分析:

        直接二分可能的爆炸半径mid,然后对于mid来说,遍历任意两点的所有组合.如果a=0的点与b=1的点的距离

AC代码:

#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;
const int maxn=100+10;
int n;
struct TwoSAT
{
    int n;
    vector<int> G[maxn*2];
    int S[maxn*2],c;
    bool mark[maxn*2];

    bool dfs(int x)
    {
        if(mark[x^1]) return false;
        if(mark[x]) return true;
        mark[x]=true;
        S[c++]=x;

        for(int i=0;i<g if return false true void init n this->n=n;
        for(int i=0;i0) mark[S[--c]]=false;
                if(!dfs(i+1)) return false;
            }
        }
        return true;
    }
}TS;
struct Point
{
    double x,y;
};
struct Node
{
    Point p[2];
}s[maxn];
double dist(int i,int vi,int j,int vj)
{
    double x1,y1,x2,y2;
    x1 = s[i].p[vi].x;
    y1 = s[i].p[vi].y;
    x2 = s[j].p[vj].x;
    y2 = s[j].p[vj].y;
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
bool ok(double mid)
{
    TS.init(n);
    for(int i=0;i<n for j="i+1;j<n;j++)" if mid ts.add_clause return ts.solve int main while i="0;i<n;i++)" scanf double l="0.0," r="20000.1;"> (1e-4) )
        {
            double mid = (R+L)/2;
            if(ok(mid)) L=mid;
            else R=mid;
        }
        printf("%.2lf\n",L);
    }
    return 0;
}
</n></g></int></cmath></vector></cstring></cstdio>
Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to completely uninstall Xbox Game Bar in Win11? Share how to uninstall Xbox Game Bar How to completely uninstall Xbox Game Bar in Win11? Share how to uninstall Xbox Game Bar Feb 10, 2024 am 09:21 AM

How to completely uninstall Win11XboxGameBar? Xbox GameBar is the game platform that comes with the system. It provides tools for game recording, screenshots and social functions. However, it takes up a lot of memory and is not easy to uninstall. Some friends want to uninstall it, but there is no way. How to completely uninstall it, let me introduce it to you below. Method 1. Use Windows Terminal 1. Press the [Win+X] key combination, or [right-click] click [Windows Start Menu] on the taskbar, and select [Terminal Administrator] from the menu item that opens. 2. User Account Control window, do you want to allow this app to make changes to your device? Click [Yes]. 3. Execute the following command: Get-AppxP

Black Myth: Wukong smashes the competition with 2.2 million Steam players mere hours after launch Black Myth: Wukong smashes the competition with 2.2 million Steam players mere hours after launch Aug 21, 2024 am 10:25 AM

The hype for Black Myth: Wukong has been felt globally as the game slowly crawled towards its launch date, and it didn't disappoint when it launched on August 20, having received a very warm welcome from the gaming community at large. After being onl

Sonic X Shadow Generations download size revealed for Nintendo Switch via official listing Sonic X Shadow Generations download size revealed for Nintendo Switch via official listing Jul 30, 2024 am 09:42 AM

Building on the success of its predecessor, Sonic Generations ($39 on Amazon), Sega is set to release Sonic X Shadow Generations on October 25th, 2024. A title that has been highly awaited for a while now, Sega is expanding on the original game's for

Sleeping Dogs: Definitive Edition for PC drops to an all-time low of $2.99 on GOG Sleeping Dogs: Definitive Edition for PC drops to an all-time low of $2.99 on GOG Aug 31, 2024 am 09:52 AM

Sleeping Dogs: Definitive Edition is currently available at a heavily discounted price of just $2.99 on GOG, offering a massive 85% reduction from its original price of $19.99. To take advantage of this deal, simply visit the game's page on GOG, add

Square Enix shooter Foamstars to go free-to-play after haemorrhaging players following February release Square Enix shooter Foamstars to go free-to-play after haemorrhaging players following February release Aug 28, 2024 pm 01:09 PM

Square Enix's Foamstars initially launched to a very strong reception, reportedly beating out smash-hit Helldivers 2 on launch day — likely owing to its launch as part of the PS Plus monthly games program. However, that player count soon dropped stee

Win11 Build 226×1.2271 preview version update, all Windows Insider channel users are invited to experience the new version of Microsoft Store Win11 Build 226×1.2271 preview version update, all Windows Insider channel users are invited to experience the new version of Microsoft Store Sep 17, 2023 am 09:29 AM

Microsoft today released the Win11Build226×1.2271 preview update to the Beta channel and invited all Windows Insider channel users to experience the new version of Microsoft Store. The latest version of Microsoft Store is 22308.1401.x.x New GamePass page: Microsoft said it has introduced a new dedicated page that allows players to explore and subscribe to PC GamePass or GamePass Ultimate. Users can learn about the many benefits of GamePass, including exclusive games, discounts, free benefits, EAPlay, etc. Microsoft hopes users will not jump to

Microsoft gives away very popular RPG adventure game Microsoft gives away very popular RPG adventure game Sep 07, 2024 am 06:39 AM

Hero of the Kingdom II is an adventure game with RPG elements in which players take on the role of a simple farmer who lives with his sister in a quiet village. But the idyll is soon disturbed by pirate raids, whereupon they set out to save the kingd

Microsoft is giving away a retro construction game at no cost, but only for a limited period. Microsoft is giving away a retro construction game at no cost, but only for a limited period. Sep 07, 2024 pm 09:30 PM

Hero of the Kindgom II is not the only game from Lonely Troops currently on offer for free in the Microsoft Store. Until September 9, gamers can also get Townpolis for free - a construction game from 2008 that regularly costs $5. Townpolis puts playe

See all articles