Pinball Game 3D Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 688    Accepted Submission(s): 276 Problem Description RD is a smart boy and excel in pinball game. However, playing common 2D p…
题意:三维空间内 n个小球,对应坐标(x,y,z).输出LIS的长度以及方案数. 首先可以先按x排序,先降低一维,然后 剩下y .z,在y上进行CDQ分治,按y的大小用前面的更新后面的.z方向离散化之后用树状数组维护就可以了. #include <set> #include <map> #include <cmath> #include <ctime> #include <queue> #include <stack> #includ…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4742 题意:求3维的LIS.. 用分治算法搞得,参考了cxlove的题解.. 首先按照x排序,然后每个三元组一个编号1-n.接下来只要考虑y和z的值,假设[l,mid]区间已经求好,那么我们对[l,r]区间按照y排序,更新[mid+1,r]区间的最优值时,只要考虑z值了,用树状数组维护z的最长LIS,遇到[mid+1,r]区间的就更新. //STATUS:C++_AC_1750MS_5348KB #…
离散化x然后用树状数组解决,排序y然后分治解决,z在分治的时候排序解决. 具体:先对y排序,solve(l,r)分成solve(l,mid),solve(mid+1,r), 然后因为是按照y排序,所以l,mid区间内的y值都小于mid+1,r.现在再对z排序,按照顺序以x做关键字插入到树状数组中,那么就可以一起解决l,mid对mid+1,r的影响. #include <iostream> #include <cstdio> #include <cstring> #inc…
hdu 5618 Jam's problem again #include <bits/stdc++.h> #define MAXN 100010 using namespace std; int n,k,T,xx; int ans[MAXN],c[MAXN],f[MAXN]; struct Node{ int x,y,z,id; }a[100010],b[100010]; inline int read(){ char ch; bool f=false; int res=0; while (…
Pinball Game 3D Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1137    Accepted Submission(s): 477 Problem Description RD is a smart boy and excel in pinball game. However, playing common 2D…
Jam's problem again Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 640    Accepted Submission(s): 210 Problem Description Jam like to solve the problem which on the 3D-axis,given N(1≤N≤100000)…
给定空间中的n个点,问每个点有多少个点小于等于自己. 先来分析简单的二维的情况,那么只要将x坐标排序,那么这样的问题就可以划分为两个子问题,,这样的分治有一个特点,即前一个子问题的解决是独立的,而后一个子问题的解决依赖于前一个子问题,即用前一个子问题来解决后一个子问题,而不是合并. 这就是cdq分治. 具体的代码如下. void cdq(int l, int r){ if(l==r) return; ; cdq(l,m); cdq(m+,r); //按y进行排序,那么问题就变成两个y递增的集合,…
题目描述 给定一个长度为N的序列S,S的每个元素pi是一个二元组(xi,yi),定义pi<pj当且仅当xi<xj并且yi<yj,求S的最长上升子序列长度 输入格式 第一行一个N,表示一共有N个元素 接下来有N行,每行包含两个正整数xi,yi 输出格式 输出一行一个整数,代表序列S的最长上升子序列的长度 一道很好的模板题,比较入门吧 CDQ分治+线段树/树状数组维护最大值就好了 #include<cstdio> #include<cstring> #include&…
http://acm.hdu.edu.cn/showproblem.php?pid=5618 题意:…… 思路:和NEUOJ那题一样的.重新写了遍理解了一下,算作处理三维偏序的模板了. #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> using namespace std; #define INF 0x3f3f3f3f #define N 100010…