题意:

    给出一个由n个点组成的凸包,以及凸包内的k个点,问是否能够在凸包上选择最多2k个点构造一个新的

  凸包,使得新的凸包覆盖原来的k个点。

    

    要求2k个点覆盖原本的k个点,只要对原k个点构造凸包,然后选择该凸包内一点O与该凸包的顶点连一条射线,其

  与大凸包相交的边的两端点即为要保留的点,小凸包的顶点个数<=k,所有结果最后一定存在。

  

    

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 100100
#define eps 1e-7
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fre freopen
#define pi acos(-1.0)
#define inf 1e9+9
#define Vector Point
const int Mod=1e9+;
typedef unsigned long long ull;
typedef long long ll;
int dcmp(double x){
if(fabs(x)<=eps) return ;
return x<?-:;
}
double ox,oy;
struct Point{
double x,y,id;
Point(){}
Point(double x,double y):x(x),y(y) {}
bool operator < (const Point &a)const { if(x==a.x) return y<a.y; return x<a.x; }
Point operator - (const Point &a)const{ return Point(x-a.x,y-a.y); }
Point operator + (const Point &a)const{ return Point(x+a.x,y+a.y); }
Point operator * (const double &a)const{ return Point(x*a,y*a); }
Point operator / (const double &a)const{ return Point(x/a,y/a); }
void read(){ scanf("%lf%lf",&x,&y); }
bool operator == (const Point &a)const{ return dcmp(x-a.x)== && dcmp(y-a.y)==; }
};
double Dot(Vector a,Vector b) { return a.x*b.x+a.y*b.y; }
ll dis(Vector a) { return sqrt(Dot(a,a)); }
double Cross(Vector a,Vector b) { return a.x*b.y-a.y*b.x; }
int ConvexHull(Point *p,int n,Point *ch){
sort(p+,p++n);
int m=;
For(i,,n){
while(m> && Cross(ch[m-]-ch[m-],p[i]-ch[m-])<=) m--;
ch[m++]=p[i];
}
int k=m;
Fore(i,n-,) {
while(m>k && Cross(ch[m-]-ch[m-],p[i]-ch[m-])<=) m--;
ch[m++]=p[i];
}
if(n>) m--;
return m;
}
Point getInsect(Point p,Vector v,Point q,Vector w) {
Vector u=p-q;
double t=Cross(w,u)/Cross(v,w);
return p+v*t;
}
Point p[],pp[],ch[],o;
bool chk(Point p1,Point p2,Point q1,Point q2) {
double c1=Cross(p2-p1,q1-p1),c2=Cross(p2-p1,q2-p1);
double c3=Dot(p2-p1,q1-p1),c4=Dot(p2-p1,q2-p1);
if(dcmp(c1)*dcmp(c2)<) {
Point cp=getInsect(p1,p2-p1,q1,q2-q1);
return Dot(cp-p1,p2-p1)>;
}
return ;
}
int n,k,res;
set<int>ans;
void solve(){
ans.clear();
scanf("%d",&n);
For(i,,n-) p[i].read();
scanf("%d",&k);
For(i,,k) pp[i].read();
int m=ConvexHull(pp,k,ch);
o=ch[];
For(i,,m-) o=(o+ch[i])/;
res=;
For(i,,m-) {
while(!chk(o,ch[i],p[res],p[(res+)%n])) res=(res+)%n;
ans.insert(res);ans.insert((res+)%n);
}
set<int>::iterator it;
cout<<"Yes"<<endl;
cout<<ans.sz<<endl;
for(it=ans.begin();it!=ans.end();it++){
if(it!=ans.begin()) printf(" ");
printf("%d",(*it)+);
}
cout<<endl;
}
int main(){
// fre("in.txt","r",stdin);
int t=;
cin>>t;
For(i,,t) solve();
return ;
}

[HDU - 5408] CRB and Farm的更多相关文章

  1. Hdu 5416 CRB and Tree (bfs)

    题目链接: Hdu 5416 CRB and Tree 题目描述: 给一棵树有n个节点,树上的每条边都有一个权值.f(u,v)代表从u到v路径上所有边权的异或值,问满足f(u,v)==m的(u, v) ...

  2. Hdu 5407 CRB and Candies (找规律)

    题目链接: Hdu 5407 CRB and Candies 题目描述: 给出一个数n,求lcm(C(n,0),C[n,1],C[n-2]......C[n][n-2],C[n][n-1],C[n][ ...

  3. HDU 5416 CRB and Tree(前缀思想+DFS)

    CRB and Tree Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tot ...

  4. hdu 5412 CRB and Queries

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5412 CRB and Queries Description There are $N$ boys i ...

  5. HDU 5412 CRB and Queries(区间第K大 树套树 按值建树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5412 Problem Description There are N boys in CodeLan ...

  6. HDU 5410 CRB and His Birthday(完全背包变形)

    CRB and His Birthday Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  7. hdu 5410 CRB and His Birthday(混合背包)

    Problem Description Today is CRB's birthday. His mom decided to buy many presents for her lovely son ...

  8. HDU 5412 CRB and Queries 动态整体二分

    Problem Description There are N boys in CodeLand.Boy i has his coding skill Ai.CRB wants to know who ...

  9. HDU - 5413 CRB and Roads

    CRB and Roads Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

随机推荐

  1. select 的字段为空,给他显示默认值

    select 的字段为空,给他显示默认值: 解决办法一: select id,name,(case when level is null then 0 else level end) as a fro ...

  2. SQL查找数据库中所有没有主键的数据表脚本

    --SQL查找数据库中所有没有主键的数据表脚本 --运行脚本后在消息中可能会显示下面现象中的一种:--(1)数据库中所有数据表都有主键(则证明所有数据表都有主键)--(2)当前数据表[数据表名]没有主 ...

  3. 小程序web-view wx.miniProgram.postMessage 坑记录

    web-view吧,其实微信官方应该是非常不支持在小程序上嵌套web的,它希望你直接用小程序上的代码,而放弃web的实现,当然,也是为了防止用小程序去嵌套别的广告页面.所以官方对web-view的操作 ...

  4. Tju_Oj_2790Fireworks Show

    这个题主要在于时间复杂度的计算,N是10的6次方,C是10的2次方,OJ系统可接受的时间是10的7次方(室友说是无数先人测出来了┭┮﹏┭┮),所以如果普通遍历的话肯定会超时.而代码中是跳着走了,相当于 ...

  5. tensorflow中的卷积和池化层(一)

    在官方tutorial的帮助下,我们已经使用了最简单的CNN用于Mnist的问题,而其实在这个过程中,主要的问题在于如何设置CNN网络,这和Caffe等框架的原理是一样的,但是tf的设置似乎更加简洁. ...

  6. c++刷题(15/100)矩阵转置,最深子树

    题目一:矩阵转置 给定一个矩阵 A, 返回 A 的转置矩阵. 矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引. 示例 1: 输入:[[1,2,3],[4,5,6],[7,8,9]] 输出 ...

  7. Linux基础-yum软件包管理

    任务目标:自定义yum仓库:createrepo,自定义repo文件,使用yum命令安装httpd软件包,卸载httpd软件包:yum –y remove 软件名 ,使用yum安装组件'KDE 桌面' ...

  8. Spring---七大核心模块

    核心容器(Spring Core) 核心容器提供Spring框架的基本功能.Spring以bean的方式组织和管理Java应用中的各个组件及其关系.Spring使用BeanFactory来产生和管理B ...

  9. JDK1.8源码之String

    一.String类型 引用博文连接:  https://blog.csdn.net/ylyg050518/article/details/52352993 一.成员变量 //用于存储字符串 priva ...

  10. [MySQL FAQ]系列 — EXPLAIN结果中哪些信息要引起关注

    我们使用EXPLAIN解析SQL执行计划时,如果有下面几种情况,就需要特别关注下了: 首先看下 type 这列的结果,如果有类型是 ALL 时,表示预计会进行全表扫描(full table scan) ...