[2018.09.12 T1] 下落的圆盘

暂无链接

下落的圆盘

题目描述

有n个圆盘从天而降! 虽然后面落下的可以盖住前面落下的,可是天神
小O觉得这样很不美观,于是他规定:所有的圆盘两两不能相交!(可以相
切)当然,陆地的大小是有限制的,具体的说,每个圆盘的圆心的x坐标必须
在[0, W]以内,y坐标必须在[0, L]以内。

天神小O想要你帮他构造一个方案。当然,因为他觉得你非常naive,他做
出了一点限制:所有圆盘的面积和不超过 15WL 1 5 W L

输入格式

第一行有三个整数:n, W, L。

第二行有n个整数,分别表示n个圆盘的半径。

输出格式

输出n行,每行2个实数,表示第i个圆盘的圆心位置。

样例输入

2 6 6
1 1

样例输出

0.0 0.0
6.0 6.0

数据范围与约定

1W,L109 1 ≤ W , L ≤ 10 9

1ri105 1 ≤ r i ≤ 10 5

5×π×(ni=1r2i)w×L 5 × π × ( ∑ i = 1 n r i 2 ) ≤ w × L

对于 40% 40 % 的数据, 1n10 1 ≤ n ≤ 10

对于 100% 100 % 的数据, 1n103 1 ≤ n ≤ 10 3

题目保证有解。

在检验答案合法性时,如果两个实数的差小于 106 10 − 6 ,我们认为它们相等。

题解

考场上写了个模拟退火,居然有 70 70 分,觉得自己很强,结果人家直接 rand r a n d 就能过。。。

正解是非常暴力的乱搞,大概可能是先按半径从大到小排个序,然后就一直 rand r a n d ,直到合法。。。

1.gif

代码
#include<bits/stdc++.h>
#define db double
#define eps 1e-6
#define random(i) cir[i].x=rand()%(w+1),cir[i].y=rand()%(l+1)
using namespace std;
const int M=1005;
struct sd{db x,y,r,id;}cir[M];
bool cmp1(sd a,sd b){return a.r>b.r;}
bool cmp2(sd a,sd b){return a.id<b.id;}
int n,w,l;
db sqr(db x){return x*x;}
db dis(sd a,sd b){return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));}
bool check(int x){for(int i=1;i<x;++i)if(dis(cir[i],cir[x])<cir[i].r+cir[x].r-eps)return 1;return 0;}
void in(){scanf("%d%d%d",&n,&w,&l);for(int i=1;i<=n;++i)scanf("%lf",&cir[i].r),cir[i].id=i;}
void ac()
{
    sort(cir+1,cir+1+n,cmp1);cir[1].x=cir[1].y=0;
    for(int i=2;i<=n;++i)for(random(i);check(i);random(i));
    sort(cir+1,cir+1+n,cmp2);
    for(int i=1;i<=n;++i)printf("%.1lf %.1lf\n",cir[i].x,cir[i].y);
}
int main(){in();ac();}
select * from (select t1.[id] as t1_id,t1.[requestId] as t1_requestId,t1.[htqsrq] as t1_htqsrq,t1.[htjzrq] as t1_htjzrq,t1.[htbh] as t1_htbh,t1.[gf] as t1_gf,t1.[xf] as t1_xf,t1.[rq] as t1_rq,t1.[fkfs] as t1_fkfs,t1.[formmodeid] as t1_formmodeid,t1.[modedatacreater] as t1_modedatacreater,t1.[modedatacreatertype] as t1_modedatacreatertype,t1.[modedatacreatedate] as t1_modedatacreatedate,t1.[modedatacreatetime] as t1_modedatacreatetime,t1.[modedatamodifier] as t1_modedatamodifier,t1.[modedatamodifydatetime] as t1_modedatamodifydatetime,t1.[form_biz_id] as t1_form_biz_id,t1.[MODEUUID] as t1_MODEUUID,t1.[htfj] as t1_htfj,t1.[zje] as t1_zje,t1.[ds] as t1_ds,t1.[zjedx] as t1_zjedx,t1.[cspp] as t1_cspp,t1.[yfk] as t1_yfk,t1.[gxid] as t1_gxid,t1.[bz] as t1_bz,t1.[gfqymc] as t1_gfqymc,t1.[gfjc] as t1_gfjc,t1.[bh] as t1_bh,t1.[jylx] as t1_jylx,t1.[cght] as t1_cght,t1.[yf] as t1_yf,t1.[yfk1] as t1_yfk1,t1.[yf11] as t1_yf11,t1.[nf] as t1_nf,t1.[rksj] as t1_rksj,t1.[cclx] as t1_cclx,t1.[cgbt] as t1_cgbt,t1.[yfk2] as t1_yfk2,t1.[sywf] as t1_sywf,t1.[yfbl] as t1_yfbl,t1.[fhbl] as t1_fhbl,t1.[yfh] as t1_yfh,t1.[sykf] as t1_sykf,t1.[hzsdlqys] as t1_hzsdlqys,t1.[sys_workflowid] as t1_sys_workflowid,t1.[cgqzyz] as t1_cgqzyz,t1.[htwjpdf] as t1_htwjpdf,t1.[cghtlc] as t1_cghtlc,t1.[htzt] as t1_htzt,t1.[qzfs] as t1_qzfs,t1.[htwjtp] as t1_htwjtp,t1.[cgqzlc] as t1_cgqzlc,t1.[sjfk] as t1_sjfk,t1.[ydkds] as t1_ydkds,t1.[chpt] as t1_chpt,t1.[lxdhchr] as t1_lxdhchr,t1.[gxsjkx] as t1_gxsjkx,t1.[hkzt] as t1_hkzt,t1.[lcfkd] as t1_lcfkd,t1.[fkzlcid] as t1_fkzlcid,t1.[mode_top_4] as t1_mode_top_4,t1.[cgdj] as t1_cgdj,t1.[mode_top_22] as t1_mode_top_22,t2.[id] as t2_id,t2.[mainid] as t2_mainid,t2.[sld] as t2_sld,t2.[ppcj] as t2_ppcj,t2.[hsdj] as t2_hsdj,t2.[bz] as t2_bz,t2.[je] as t2_je,t2.[xhggyt] as t2_xhggyt,t2.[mxgxid] as t2_mxgxid,t2.[dqkckc] as t2_dqkckc,t2.[rkhkc] as t2_rkhkc,t2.[yf] as t2_yf,t2.[yldjbhyf] as t2_yldjbhyf,SELECT year(rksj) as 年 FROM uf_gfht as cus_年年 from uf_gfht t1 INNER join uf_gfht_dt1 t2 on t1.id = t2.mainid) tmp1 where t1 错在哪里
最新发布
05-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ShadyPi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值