hdu4462 Scaring the Birds】的更多相关文章

Scaring the Birds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 970    Accepted Submission(s): 329 Problem Description It’s harvest season now!  Farmer John plants a lot of corn. There are ma…
It's harvest season now! Farmer John plants a lot of corn. There are many birds living around his corn field. These birds keep stealing his corn all the time. John can't stand with that any more. He decides to put some scarecrows in the field to driv…
题意:给定一个 n*n的矩阵,在一些位置放上稻草人,每个稻草人的范围是一定,问你最少几个能覆盖整个矩阵. 析:稻草人最多才10个,所以考虑暴力,然后利用二进制法,很容易求解,并且时间很少0ms,注意有一个坑,就是那些指定的位置是可以不用覆盖的, 当时WA一次. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream&…
题意: N*N的矩阵中有M个点能够放稻草人.且给覆盖距离R 每一个稻草人能覆曼哈顿距离R以内的点 问最少须要多少个稻草人 思路: 由于范围非常小,直接能够暴力 注意稻草人所在的位置是不须要被覆盖的 代码: #include"cstdlib" #include"cstdio" #include"cstring" #include"cmath" #include"queue" #include"alg…
题目链接:pid=4462">传送门 题意:一个n*n的区域,有m个位置是能够放稻草人的.其余都是玉米.对于每一个位置(x,y)所放稻草人都有个作用范围ri, 即abs(x-i)+abs(y-j)<=r,(i,j)为作用范围内.问至少要在几个位置上放稻草人,才干覆盖全部的玉米,若不可能则输出-1. 有一个trick,就是放稻草人的位置不用被覆盖 eg: input: 2 4 1 1 1 2 2 1 2 2 0 0 0 0 output: 0 0 代码例如以下: #include &l…
http://acm.hdu.edu.cn/showproblem.php?pid=4462 题意:有一个n*n的地图,有k个空地可以放稻草人,给出每个空地可以放的稻草人属性,属性中有个R代表这个位置可以守卫的范围,问最少需要放多少个稻草人才可以守卫这个地图. 思路:可以状态压缩一样枚举所有的状态(为毛昨天想不到),然后就根据这个状态选择哪个空地接着暴力染色地图这样.注意k个地方是空地,不用守卫的. #include <cstdio> #include <cstring> #inc…
Scaring the Birds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1257    Accepted Submission(s): 420 Problem Description It’s harvest season now!  Farmer John plants a lot of corn. There are m…
题目传送门排行榜 一个人做了12年北大出的题,自己还是太弱了,图论的知识忘光光,最小生成树裸题写不来,Dijkstra TLE不知道用SPFA. 简单几何(点到线段的距离) + 三分 B Stealing a Cake 题意:圆外一个点先到圆再到矩形的最短距离. 分析:由于圆在[0, PI]和[PI, PI*2]上是单峰函数,用三分求极值,应该在[0,PI*2]上也算单峰函数吧. /************************************************ * Author…
Friend Chains http://acm.hdu.edu.cn/showproblem.php?pid=4460 图的最远两点距离,任意选个点bfs,如果有不能到的点直接-1.然后对于所有距离最远的点都bfs一次.最坏n^2 邻接表 #include<cstdio> #include<cstring> #include<iostream> #include<queue> #include<map> #define mt(a,b) mems…
1118. Birds in Forest (25) 时间限制 150 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supp…