没有正确分析路径可能的条数,它是指数增长的,会爆long long。

然后就是正反两次时间分治。

另一个就是max with count,即带计数的最值,即除了记录最值,还要记录最值取得的次数。

 /**************************************************************
Problem: 2244
User: idy002
Language: C++
Result: Accepted
Time:4108 ms
Memory:4520 kb
****************************************************************/ #include <cstdio>
#include <algorithm>
#define oo 0x3f3f3f3f
#define N 50010
using namespace std; typedef bool (*Cmp)( int a, int b ); struct Point {
int x, y;
Point(){}
Point( int x, int y ):x(x),y(y){}
};
struct Info {
int v;
long double c;
Info(){}
Info( int v, long double c ):v(v),c(c){}
void add( Info o ) {
if( o.v>v )
*this = o;
else if( o.v==v )
c += o.c;
}
}; int n;
Point pts[N];
Info dp[][N];
Info bit[N];
int q[N];
Cmp cmp;
int disc[N], dtot;
long double ans[N]; bool cmpa( int a, int b ) {
if( pts[a].x!=pts[b].x ) return pts[a].x<pts[b].x;
if( pts[a].y!=pts[b].y ) return pts[a].y<pts[b].y;
return a<b;
}
bool cmpb( int a, int b ) {
if( pts[a].x!=pts[b].x ) return pts[a].x>pts[b].x;
if( pts[a].y!=pts[b].y ) return pts[a].y>pts[b].y;
return a<b;
}
void modify( int pos, Info o ) {
if( cmp==cmpb ) pos = dtot+-pos;
for( int i=pos; i<=dtot; i+=i&-i )
bit[i].add(o);
}
void clear( int pos ) {
if( cmp==cmpb ) pos = dtot+-pos;
for( int i=pos; i<=dtot; i+=i&-i )
bit[i] = Info(-oo,);
}
Info query( int pos ) {
if( cmp==cmpb ) pos = dtot+-pos;
Info o(-oo,);
for( int i=pos; i; i-=i&-i )
o.add(bit[i]);
return o;
}
void cdq( Info dp[], int lf, int rg ) {
if( lf==rg ) {
dp[lf].add( Info(,) );
return;
}
int mid=(lf+rg)>>;
cdq( dp, lf, mid );
for( int i=lf; i<=rg; i++ )
q[i] = i;
sort( q+lf, q+rg+, cmp );
for( int t=lf; t<=rg; t++ ) {
int i=q[t];
if( i<=mid ) {
modify( pts[i].y, dp[i] );
} else {
Info o = query(pts[i].y);
o.v++;
dp[i].add( o );
}
}
for( int t=lf; t<=rg; t++ ) {
int i=q[t];
if( i<=mid )
clear( pts[i].y );
}
cdq( dp, mid+, rg );
}
int main() {
scanf( "%d", &n );
for( int i=,x,y; i<=n; i++ ) {
scanf( "%d%d", &x, &y );
pts[i] = Point(x,y);
disc[++dtot] = y;
}
reverse( pts+, pts++n );
sort( disc+, disc++dtot );
dtot = unique( disc+, disc++dtot ) - disc - ;
for( int i=; i<=n; i++ )
pts[i].y = lower_bound( disc+, disc++dtot, pts[i].y ) - disc; cmp = cmpa;
cdq( dp[], , n );
cmp = cmpb;
reverse( pts+, pts++n );
cdq( dp[], , n );
reverse( dp[]+, dp[]++n ); Info info(-oo,);
for( int i=; i<=n; i++ )
info.add( dp[][i] );
printf( "%d\n", info.v );
for( int i=; i<=n; i++ ) {
if( dp[][i].v+dp[][i].v- == info.v ) {
ans[i] = dp[][i].c*dp[][i].c/info.c;
} else
ans[i] = 0.0;
}
reverse( ans+, ans++n );
for( int i=; i<=n; i++ )
printf( "%.5Lf\n", ans[i] );
}

bzoj 2244的更多相关文章

  1. bzoj 2244 [SDOI2011]拦截导弹(DP+CDQ分治+BIT)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2244 [题意] 给定n个二元组,求出最长不上升子序列和各颗导弹被拦截的概率. [思路] ...

  2. bzoj 2244: [SDOI2011]拦截导弹 cdq分治

    2244: [SDOI2011]拦截导弹 Time Limit: 30 Sec  Memory Limit: 512 MBSec  Special JudgeSubmit: 237  Solved: ...

  3. BZOJ 2244: [SDOI2011]拦截导弹 DP+CDQ分治

    2244: [SDOI2011]拦截导弹 Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度.并且能够拦截 ...

  4. bzoj 2244: [SDOI2011]拦截导弹

    #include<cstdio> #include<iostream> #include<algorithm> #define M 100009 using nam ...

  5. BZOJ 2244: [SDOI2011]拦截导弹 [CDQ分治 树状数组]

    传送门 题意:三维最长不上升子序列以及每个元素出现在最长不上升子序列的概率 $1A$了好开心 首先需要从左右各求一遍,长度就是$F[0][i]+F[1][i]-1$,次数就是$G[0][i]*G[1] ...

  6. bzoj 2244 [SDOI2011]拦截导弹(dp+CDQ+树状数组)

    传送门 题解 看了半天完全没发现这东西和CDQ有什么关系…… 先把原序列翻转,求起来方便 然后把每一个位置表示成$(a,b,c)$其中$a$表示位置,$b$表示高度,$c$表示速度,求有多少个位置$a ...

  7. BZOJ - 2244 拦截导弹 (dp,CDQ分治+树状数组优化)

    题目链接 dp进阶之CDQ分治优化dp. 前置技能:dp基本功底,CDQ分治,树状数组. 问题等价于求二维最长上升子序列,是一个三维偏序问题(时间也算一维). 设$dp[i]=(l,x)$为以第i枚导 ...

  8. BZOJ 2244 [SDOI2011]拦截导弹 ——CDQ分治

    三维偏序,直接CDQ硬上. 正反两次CDQ统计结尾的方案数,最后统计即可. #include <cstdio> #include <cstring> #include < ...

  9. BZOJ 2244 [SDOI2011]拦截导弹 (三维偏序CDQ+线段树)

    题目大意: 洛谷传送门 不愧为SDOI的duliu题 第一问?二元组的最长不上升子序列长度?裸的三维偏序问题,直接上$CDQ$ 由于是不上升,需要查询某一范围的最大值,并不是前缀最大值,建议用线段树实 ...

随机推荐

  1. aarch64_j2

    js-yui2-2.9.0-10.fc24.noarch.rpm 2016-09-25 07:06 1.2M fedora Mirroring Project js-yui2-jenkins-2.9. ...

  2. MVVM模式的 数据绑定

    数据绑定要达到的效果 数据绑定要达到什么效果呢,就是在界面中绑定了数据源之后,数据在界面上的修改能反映到绑定源,同时绑定源的修改也能反映到界面上.从界面反映到绑定的数据源是很容易理解的,因为在绑定过程 ...

  3. RabbitMQ--Hello world!(一)

    Introduction RabbitMQ is a message broker. The principal idea is pretty simple: it accepts and forwa ...

  4. 使用的vue、elementUI、vuex、express、mongoDB的单页应用

    基于vue.vuex.express.mongodb的一个单页应用,包括前后端,前端主要是使用vue,后端是node的express,数据库是使用的mongodb 1.下载使用 git clone h ...

  5. 利用mysql的binlog恢复数据

    MySQL Binary Log也就是常说的bin-log, ,是mysql执行改动产生的二进制日志文件,其主要作用有两个: * 数据回复 * 主从数据库.用于slave端执行增删改,保持与maste ...

  6. 数据库-mysql储存过程

    存储过程是一个SQL语句集合,当主动去调用存储过程时,其中内部的SQL语句会按照逻辑执行. 一:创建存储过程 MariaDB [test2]> delimiter // MariaDB [tes ...

  7. P2184 【贪婪大陆】

    看到全是线段树或者树状数组写法,就来提供一发全网唯一cdq分治三维偏序解法吧 容易发现,这个题的查询就是对于每个区间l,r,查询有多少个修改区间li,ri与l,r有交集 转化为数学语言,就是查询满足l ...

  8. MySQL学习笔记:exists和in的区别

    一.exists函数 表示存在,常常与子查询配合使用. 用于检查子查询是否至少会返回一行数据,该子查询实际上并不返回任何数据,而是返回值True或False. 当子查询返回为真时,则外层查询语句将进行 ...

  9. VMware虚拟机的三种联网方法及原理(转)

    转自:http://blog.chinaunix.net/uid-24876683-id-3593774.html 一.Brigde——桥接 :默认使用VMnet0 .原理: Bridge 桥&quo ...

  10. Python 让两个print()函数的输出打印在一行内

    1.两个连续的print()函数为什么在输出时内容会分行显示? 解:print()中有两个默认参数 sep 和 end,其中sep是代替分隔符,end是代替末尾的换行符,默认使用‘,’代替空格,且默认 ...