HDU 2295 Radar (重複覆蓋)
Radar
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2280 Accepted Submission(s): 897
Each of the last M lines consists of the coordinate of a radar station.
All coordinates are separated by one space.
Technical Specification
1. 1 ≤ T ≤ 20
2. 1 ≤ N, M ≤ 50
3. 1 ≤ K ≤ M
4. 0 ≤ X, Y ≤ 1000 Output For each test case, output the radius on a single line, rounded to six fractional digits. Sample Input 1 3 3 2 3 4 3 1 5 4 1 1 2 2 3 3 Sample Output 2.236068 Source
題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=2295
二分答案, 然後使用重複覆蓋的Dancing Links模板進行判斷,看使用K個能不能覆蓋n個點
1 /* *********************************************** 2 Author :kuangbin 3 Created Time :2014/5/26 22:20:05 4 File Name :E:\2014ACM\專題學習\DLX\HDU2295.cpp 5 ************************************************ */ 6 7 #include <stdio.h> 8#include <string.h> 9 #include <iostream> 10 #include <algorithm> 11 #include <vector> 12 #include <queue> 13 #include <set> 14 #include <map> 15 #include <string> 16 #include <math.h> 17 #include <stdlib.h> 18 #include <time.h> 19using namespace std; 20 const int maxnode = 3000; 21 const int MaxM = 55; 22 const int MaxN = 55; 23 int K; 24 struct DLX 25 { 26 int n,m,size; 27 int U[maxnode],D[maxnode],R[maxnode],L[maxnode],Row[maxnode],Col[maxnode]; 28 int H[MaxN],S[MaxN]; 29 int ands,ans[MaxN]; 30 void init(int _n,int _m) 31 { 32 n = _n; 33 m = _m; 34 for(int i = 0;i <= m;i++) 35 { 36 S[i] = 0; 37 U[i] = D[i] = i; 38 L[i] = i-1; 39 R[i] = i+1; 40 } 41 R[m] = 0; L[0] = m; 42 size = m; 43 for(int i = 1;i <= n;i++) 44 H[i] = -1; 45 } 46 void Link(int r,int c) 47 { 48 ++S[Col[++size]=c]; 49 Row[size] = r; 50 D[size] = D[c]; 51 U[D[c]] = size; 52 U[size] = c; 53 D[c] = size; 54 if(H[r] < 0)H[r] = L[size] = R[size] = size; 55 else 56 { 57 R[size] = R[H[r]]; 58 L[R[H[r]]] = size; 59 L[size] = H[r]; 60 R[H[r]] = size; 61 } 62 } 63 void remove(int c) 64 { 65 for(int i = D[c];i != c;i = D[i]) 66 L[R[i]] = L[i], R[L[i]] = R[i]; 67 } 68 void resume(int c) 69 { 70 for(int i = U[c];i != c;i = U[i]) 71 L[R[i]]=R[L[i]]=i; 72 } 73 bool v[maxnode]; 74 int f() 75 { 76 int ret = 0; 77 for(int c = R[0];c != 0;c = R[c])v[c] = true; 78 for(int c = R[0];c != 0;c = R[c]) 79 if(v[c]) 80 { 81 ret++; 82 v[c] = false; 83 for(int i = D[c];i != c;i = D[i]) 84 for(int j = R[i];j != i;j = R[j]) 85 v[Col[j]] = false; 86 } 87 return ret; 88 89 } 90 bool Dance(int d) 91 { 92 if(d + f() > K)return false; 93 if(R[0] == 0)return d <= K; 94 int c = R[0]; 95 for(int i = R[0];i != 0;i = R[i]) 96 if(S[i] < S[c]) 97 c = i; 98 for(int i = D[c];i != c;i = D[i]) 99 { 100 remove(i); 101 for(int j = R[i];j != i;j = R[j])remove(j); 102 if(Dance(d+1))return true; 103 for(int j = L[i];j != i;j = L[j])resume(j); 104 resume(i); 105 } 106 return false; 107 } 108 }; 109 DLX g; 110 const double eps = 1e-8; 111 struct Point 112 { 113 int x,y; 114 void input() 115 { 116 scanf("%d%d",&x,&y); 117 } 118 }city[MaxM],station[MaxN]; 119 double dis(Point a,Point b) 120 { 121 return sqrt((double)(a.x-b.x)*(a.x-b.x)+(double)(a.y-b.y)*(a.y-b.y)); 122 } 123 124 int main() 125 { 126 //freopen("in.txt","r",stdin); 127 //freopen("out.txt","w",stdout); 128 int T; 129 int n,m; 130 scanf("%d",&T); 131 while(T--) 132 { 133 scanf("%d%d%d",&n,&m,&K); 134 for(int i = 0;i < n;i++)city[i].input(); 135 for(int i = 0;i < m;i++)station[i].input(); 136 double l = 0, r = 1e8; 137 while(r-l >= eps) 138 { 139 double mid = (l+r)/2; 140 g.init(m,n); 141 for(int i = 0;i < m;i++) 142 for(int j = 0;j < n;j++) 143 if(dis(station[i],city[j]) < mid - eps) 144 g.Link(i+1,j+1); 145 if(g.Dance(0))r = mid-eps; 146 else l = mid+eps; 147 } 148 printf("%.6lf\n",l); 149 } 150 return 0; 151 }
相關推薦
HDU 2295 Radar (重複覆蓋)
Radar Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2280 Accepted Submission(s): 897 Problem
FZU 1686 神龍的難題 (重複覆蓋)
Problem 1686 神龍的難題 Accept: 397 Submit: 1258Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description 這是個劍與魔法的世界.英雄和魔物同在,動盪和
HDU 4386 Quadrilateral(數學啊)
algo data 長度 please sca wan post play dsm 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=4386 Problem Description One day the li
HDU 6053 TrickGCD(分塊)
%d space 復雜 cstring 前綴 == str 結果 logs 【題目鏈接】 http://acm.hdu.edu.cn/showproblem.php?pid=6053 【題目大意】 給出一個數列每個位置可以取到的最大值, 問這個
數據結構 集合_集合實例(集合覆蓋)
不存在 人員 list 組成 elm != 文件 mem 組合數 集合覆蓋是一種優化求解問題,對很多組合數學和資源選擇問題給出了很好的抽象模型。 問題如下:給定一個集合S,集合P由集合S的子集A1到An組成,集合C由集合P中的一個或多個子集組成。如果S中的每個成員都包含在C
hdu 5033 buiding(單調棧)
com atan namespace 頂上 嚴格 include query 關系 位置 hdu 5033 buiding(單調棧) 某年某月某天,馬特去了一個小鎮。這個小鎮如此狹窄,以至於他可以把小鎮當作一個樞紐。在鎮上有一些摩天大樓,其中一棟位於xi,高度為hi。所有
hdu 5521 Meeting(最短路)
names n) can style air ima pid hid con 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=5521 題意:有1-n共n個點,給出m個塊(完全圖),並知道塊內各點之間互相到達花費時
題解報告:hdu 2196 Computer(樹形dp)
put cte height ont rst sed mem tle 技術 Problem Description A school bought the first computer some time ago(so this computer‘s id is 1). D
hdu 5724 Chess (SG函式)
題目連結:hdu 5724 題意:有一個n行20列的棋盤,棋盤上分佈著一些棋子,A、B兩人輪流下棋,A先手,每次操作可以將某個棋子放到自己右邊的第一個空位(也就是說右邊如果已經有子,可以跳過它,沒有就右移一步),但最多20列,絕對不能超過棋盤,無棋可走的輸。 題解:進行狀態壓縮,bit來
語句覆蓋、條件覆蓋(分支覆蓋)、判定覆蓋、條件-判定覆蓋、組合覆蓋、路徑覆蓋 的區別
文章轉自:https://blog.csdn.net/virus2014/article/details/51217026 1語句覆蓋 使所有的判斷語句都能執行一次的條件案例,例如有兩個if語句,那麼就至少需要兩個測試用例 2判定覆蓋(分支覆蓋)
HDU - 2571 命運(dp+思維)
題目連結 題目:每次可以往下走一步,往右走一步,往右走到格子座標的k倍,找到最佳的走法,使和最大; 所以每個格子(x,y)是由(x-1,y),或者(x,y-1),或者x相同,y0可以被y整除的格子走到的,每次選最大值就行了; 注意有負值; #include <iostream&
HDU-2295___Radar——二分 + DLX重複覆蓋
題目連結:點我啊╭(╯^╰)╮ 題目大意: n n
【Eddy's AC難題】【HDU - 2200】(數學規律)
題目: Eddy是個ACMer,他不僅喜歡做ACM題,而且對於Ranklist中每個人的ac數量也有一定的研究,他在無聊時經常在紙上把Ranklist上每個人的ac題目的數量摘錄下來,然後從中選擇一部分人(或者全部)按照ac的數量分成兩組進行比較,他想使第一組中的最小ac數大於第二組中的最大
【 HDU Today 】【HDU - 2112】(dijkstra+map)
題目: 經過錦囊相助,海東集團終於度過了危機,從此,HDU的發展就一直順風順水,到了2050年,集團已經相當規模了,據說進入了錢江肉絲經濟開發區500強。這時候,XHD夫婦也退居了二線,並在風景秀美的諸暨市浬浦鎮陶姚村買了個房子,開始安度晚年了。 這樣住了一段時間,徐總對當地的交
HDU 1686 Oulipo (hash演算法)
Oulipo Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2553
hdu 3763 CD(二分查詢) Java實現
題意:求集合A和B中有幾個相同的元素,其中集合中元素已經按升序排好,集合的元素個數n<=1000000 分析:集合中的元素已經按升序排好,只要對B中每個元素在A中進行二分查詢就解
Hdu 4870 Rating(概率期望)
A little girl loves programming competition very much. Recently, she has found a new kind of programming competition named “TopTopT
基礎算法系列之排序演算法-7.希爾排序 並解決hdu 1425問題(java實現)
我們從最初的氣泡排序演算法,到上篇文章的折半插入排序演算法,我們一共學習了5種排序演算法,相信以大家的聰明才智肯定都消化了^_^。在本篇文章中,我們又將學習第6種排序演算法——希爾排序演算法。那就讓我們直奔主題吧。 希爾排序 讓我們回想一下直接插入排序演算
HDU 4714 Tree2cycle(樹形dp)
題解: 根據題目,我們可以知道只要求不是根的點所連點子鏈個數-1再加上根所連的子鏈個數-2為刪條的條數,就是可以這個樹可以分成多少條鏈,所刪條數*2+1就是答案了。 #include <algorithm> #include <iostream>
HDU-5521 Meeting(最短路)
HDU-5521 Meeting (最短路) 題目大意 給標記從1-n的節點,並且進行了分塊(分塊可能會有重合),第i個分塊內部有sis_isi個節點,節點兩兩之間都有路徑相連,通過的時間都是tit_iti。現在一頭奶牛從節點1出發,另一頭從n出發,想找一箇