青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

oyjpArt ACM/ICPC算法程序設計空間

// I am new in programming, welcome to my blog
I am oyjpart(alpc12, 四城)
posts - 224, comments - 694, trackbacks - 0, articles - 6

PKU 1328 Radar Installation

Posted on 2007-06-22 20:00 oyjpart 閱讀(3000) 評論(0)  編輯 收藏 引用 所屬分類: ACM/ICPC或其他比賽

Radar Installation
Time Limit:1000MS  Memory Limit:10000K
Total Submit:2704 Accepted:564

Description
Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, so an island in the sea can be covered by a radius installation, if the distance between them is at most d.

We use Cartesian coordinate system, defining the coasting is the x-axis. The sea side is above x-axis, and the land side below. Given the position of each island in the sea, and given the distance of the coverage of the radar installation, your task is to write a program to find the minimal number of radar installations to cover all the islands. Note that the position of an island is represented by its x-y coordinates.


Figure A Sample Input of Radar Installations



 

Input
The input consists of several test cases. The first line of each case contains two integers n (1<=n<=1000) and d, where n is the number of islands in the sea and d is the distance of coverage of the radar installation. This is followed by n lines each containing two integers representing the coordinate of the position of each island. Then a blank line follows to separate the cases.

The input is terminated by a line containing pair of zeros

Output
For each test case output one line consisting of the test case number followed by the minimal number of radar installations needed. "-1" installation means no solution for that case.

Sample Input

3 2
1 2
-3 1
2 1
1 2
0 2
0 0

 

Sample Output

Case 1: 2
Case 2: 1

 

Source
Beijing 2002


Algorithm: Greedy
Step 1: 輸入數據 如果有一個點的y坐標大于d 直接輸出-1 長生相應的區間(在某一個區間里任意放置一個Radar 則是這個Island可視)
Step 2: 按照左端點排序(如果左端點相等 則必須按右邊反向排序, 理由在于下一步為了篩選出包含的 必須的把大范圍的放到前面) 注意這里面最好要用浮點判斷規則
Step 3: 利用Stack對這些區間做預處理 把被包含的區間標識出來
Step 4: 貪心選擇右端的點

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;

const int N = 1000;
const double EPS = 1e-7;

struct E { double a, b; } e[N];
int n, d;
bool ava[N];
double p[N];

inline int dblcmp(double a, double b) {
 if( fabs(a-b) < EPS ) return 0;
 if( a-b > 0 ) return 1;
 return -1;
}

bool operator<(const E& a, const E& b) {
 if(dblcmp(a.a, b.a) == 0)
  return dblcmp(a.b, b.b) == 1;
 return dblcmp(a.a, b.a) == -1;
}


int main() {
 int i, j, x, y;
 int tc = 0;
 while(scanf("%d %d", &n, &d), n + d) {
  tc++;
  int ok = 1;
  for(i = 0; i < n; ++i) {
   scanf("%d %d", &x, &y);
   if(y > d) ok = 0;
   double offset = sqrt ( d * d - y * y );
   e[i].a = x - offset, e[i].b = x + offset;
   ava[i] = 1;
  }
  if(!ok) { printf("Case %d: -1\n", tc); continue; }
  sort(e, e + n);
  int stack[N], top = 0;
  stack[top++] = 0;
  for(i = 1; i < n; ++i) {
   while(top > 0 && dblcmp(e[stack[top-1]].b, e[i].b) != -1)  {
    ava[stack[--top]] = 0;
   }
   stack[top++] = i;
  }
  
  for(i = 0; !ava[i]; ++i);
  p[i] = e[i].b;
  int cnt = 1;
  for(i = i+1; i < n; ++i) if(ava[i]) {
   for(j = i-1; !ava[j]; j--);
   if(p[j] >= e[i].a)  p[i] = p[j];
   else { p[i] = e[i].b; cnt++; }
  }
  printf("Case %d: %d\n", tc, cnt);
 }
 return 0;
}

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产一本一道久久香蕉| 欧美视频在线一区二区三区| 欧美午夜精彩| 亚洲欧美经典视频| 欧美激情小视频| 欧美在线一级视频| 国产精品免费看片| 亚洲综合精品| 亚洲乱码视频| 欧美另类高清视频在线| 久久美女艺术照精彩视频福利播放| 欧美日韩精品高清| 一区二区三区欧美日韩| 亚洲国产网站| 欧美成人在线免费观看| 亚洲第一久久影院| 久久这里有精品15一区二区三区| 亚洲线精品一区二区三区八戒| 欧美精品网站| 亚洲天堂久久| 一本一本久久a久久精品牛牛影视| 欧美日韩不卡视频| 在线亚洲免费视频| 亚洲午夜一区二区| 国产精品日韩高清| 久久精品国产91精品亚洲| 性欧美8khd高清极品| 中国av一区| 国产精品福利影院| 午夜精品福利一区二区三区av| 亚洲素人一区二区| 国产亚洲精品一区二区| 玖玖综合伊人| 欧美freesex交免费视频| 亚洲精品资源| 亚洲欧美一区二区视频| 午夜久久福利| 亚洲风情亚aⅴ在线发布| 亚洲一区二区黄色| 狠狠入ady亚洲精品经典电影| 久久午夜精品| 欧美国产欧美亚洲国产日韩mv天天看完整 | 久久精品欧美日韩| 亚洲美女精品成人在线视频| 亚洲性图久久| 亚洲国产欧美久久| 亚洲国产成人在线播放| 国产精品分类| 欧美成人亚洲成人| 欧美性大战久久久久久久| 久久精品观看| 欧美激情一区| 久久激情网站| 欧美日韩一区二区免费视频| 久久久一区二区| 欧美日韩一区精品| 欧美sm视频| 国产精品第三页| 欧美激情一区二区三区四区| 99综合在线| 亚洲福利视频网| 亚洲欧美日韩精品综合在线观看| 亚洲国产欧美另类丝袜| 先锋影音一区二区三区| 一区二区三区免费看| 一区二区三区.www| 欲色影视综合吧| 亚洲欧美国产日韩中文字幕| 99精品视频一区| 久久精品人人做人人综合| 亚洲在线黄色| 欧美激情精品久久久| 久热国产精品| 欧美精品久久久久久久久老牛影院| 久久精精品视频| 国产精品久久91| 亚洲巨乳在线| 亚洲欧洲一区二区天堂久久| 欧美一区二区三区久久精品| 亚洲欧美日韩国产精品| 欧美视频在线观看| 亚洲精品社区| 日韩一级二级三级| 欧美福利一区二区| 欧美aa在线视频| 黄色日韩在线| 久久久久久穴| 蜜桃av噜噜一区| 国产一区二区三区成人欧美日韩在线观看 | 亚洲美女网站| 99国产精品一区| 欧美激情国产高清| 亚洲精品久久久蜜桃| 亚洲免费观看| 欧美日韩情趣电影| 一本久道久久综合婷婷鲸鱼| 136国产福利精品导航网址应用| 久久精品卡一| 欧美激情久久久| 亚洲剧情一区二区| 欧美日韩一区二区在线 | 亚洲区国产区| 欧美伦理91i| 在线综合视频| 羞羞视频在线观看欧美| 国产日韩一区二区三区| 久久久亚洲高清| 亚洲国产视频一区二区| 一区二区免费在线播放| 国产精品美女999| 欧美一级午夜免费电影| 两个人的视频www国产精品| 国产女主播一区| 久久久久久久综合狠狠综合| 亚洲国产欧美一区| 亚洲欧美另类在线| 亚洲日本黄色| 精品成人免费| 国产精品亚洲综合天堂夜夜| 免费毛片一区二区三区久久久| 亚洲一区在线看| 亚洲精品乱码久久久久久蜜桃麻豆 | 欧美日本韩国一区| 久久久久久有精品国产| 亚洲欧美中日韩| 一区二区三区高清不卡| 欧美黄色成人网| 久久尤物视频| 久久久国产精品一区二区三区| 亚洲小少妇裸体bbw| 日韩午夜av| 亚洲黄色影片| 在线观看成人一级片| 国产欧美日韩麻豆91| 国产精品白丝av嫩草影院| 欧美激情第9页| 欧美aa在线视频| 欧美成人精品高清在线播放| 久久精品视频在线播放| 欧美在线亚洲在线| 欧美资源在线观看| 午夜欧美理论片| 亚洲女同性videos| 亚洲性感美女99在线| 亚洲网站视频| 亚洲一区二区在线看| 亚洲免费在线观看| 亚洲男人av电影| 午夜国产精品视频免费体验区| 亚洲一级电影| 午夜视频久久久久久| 香蕉成人久久| 欧美一区激情视频在线观看| 久久动漫亚洲| 久久琪琪电影院| 欧美大片va欧美在线播放| 欧美.www| 欧美视频免费| 国产欧美韩日| 极品尤物av久久免费看| 加勒比av一区二区| 亚洲黑丝一区二区| 一本色道久久加勒比精品| 99riav久久精品riav| 亚洲自拍偷拍网址| 欧美在线不卡视频| 欧美成人精品三级在线观看 | 9国产精品视频| 亚洲欧美激情视频在线观看一区二区三区| 中文欧美日韩| 久久激情综合网| 欧美成人免费小视频| 亚洲免费福利视频| 小嫩嫩精品导航| 久久综合给合久久狠狠狠97色69| 欧美国产在线电影| 国产精品视频你懂的| 一区二区亚洲欧洲国产日韩| 日韩午夜精品| 久久精品国产一区二区三 | 亚洲激情视频在线| 亚洲一二三区视频在线观看| 欧美一区二区观看视频| 欧美freesex8一10精品| 99精品99久久久久久宅男| 久久国产精品久久w女人spa| 欧美激情一区二区三区在线视频观看 | 久久久综合精品| 欧美亚州在线观看| 1000部精品久久久久久久久| 在线视频精品一| 免费91麻豆精品国产自产在线观看| 亚洲国产精品免费| 久久不见久久见免费视频1| 欧美日本在线| 在线观看亚洲一区| 欧美一区二区在线免费播放| 亚洲激情欧美| 久久精品视频一| 国产伦精品一区二区三区免费迷|