没有正确分析路径可能的条数,它是指数增长的,会爆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. 创建spring boot项目

    一.创建项目 1.输入https://start.spring.io/ 2.填写group.artifact 3.选择依赖的jar 4.点击创建项目 二.导入项目 1.eclipse的package ...

  2. Asp.Net使用百度编辑器(ueditor)

    1.  1.4.3以上版本将不再承诺支持ie6/ie7. 2.如果是aspx 需要加上  ValidateRequest="false" 3.Web.config <syst ...

  3. The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context,

    在iis7.0布署网站后运行的错误,大致意思是:数据保护操作是不成功的.这可能是由于没有为当前线程的用户加载用户配置文件的导致 解决办法: 先为自己的网站新建一个应用程序池,然后新建的应用程序池上右键 ...

  4. cocos2d-x 日志...

    cocos2d-x  日志... http://blog.csdn.net/themagickeyjianan/article/details/39008297http://blog.csdn.net ...

  5. php 中更简洁的三元运算符 ?:

    PHP 三元运算符是对参数赋值时候的一个简洁的主要用法. 一个主要的用法: PHP 三元运算符能够让你在一行代码中描述判定代码, 从而替换掉类似以下的代码: <?php if (isset($v ...

  6. KVM virsh常用命令篇

    1.查看运行的虚拟机 virsh list 2.查看所有的虚拟机(关闭和运行的虚拟机) virsh list --all 3.连接虚拟机 virsh console +域名(虚拟机的名称) 4.退出虚 ...

  7. java基础47 装饰着模式设计

    1.装饰者模式 增强一个类的功能,而且还可以让这些装饰类相互装饰 2.装饰者设计模式的步骤 1.在装饰类的内部维护一个被装饰类的引用    2.让装饰者有一个共同的父类或者父接口 3.实例 packa ...

  8. MyBatis3.4.0以上的分页插件错误:Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.stateme

    错误: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named p ...

  9. HTML网页自动跳转

    <meta http-equiv="refresh" content="3;URL=res.html">

  10. Codefroces 628B New Skateboard(数位+思维)

    题目链接:http://codeforces.com/contest/628/problem/B 题目大意:给你一段数字串s(1?≤?|s|?≤?3·10^5),求该字符串有多少子串是4的倍数.解题思 ...