题目链接 BZOJ2924 题解 题面有误..是\(45°\) 如果两个点间连线与\(x\)轴夹角在\(45°\)以内,那么它们之间连边 求最小路径覆盖 = 最长反链 由于\(45°\)比较难搞,我们利用复数翻转一下,逆时针旋转\(45°\) 这样就求一条从左上到右下的最长链 我们将所有点按\(x\)排序,令\(f[i]\)表示\(i\)结尾的最长链 那么 \[f[i] = max\{f[j] + 1\} \quad [j < i \; y_j > y_i]\] 离散化一下用树状数组优化 #i…
首先旋转坐标系 $x'=x-y$ $y'=-x-y$ 则对于一个点,它下一步可以往它左上角任意一个点连线. 根据Dilworth定理,答案=这个偏序集最长反链的长度. 设f[i]为到i点为止的最长反链长度,则 f[i]=max(f[j])+1,j在i的左下角 按x坐标排序后用树状数组优化DP即可,时间复杂度$O(n\log n)$. #include<cstdio> #include<algorithm> #define N 30010 int n,i,j,x,y,b[N],bit…
题意:给定N条线段,每条线段的两个端点L和R都是整数.然后给出M个询问,每次询问给定两个区间[L1,R1]和[L2,R2],问有多少条线段满足:L1≤L≤R1 , L2≤R≤R2 ? 题解,采用离线做法,先将所有线段和询问区间全部保存.然后将每个询问[L1,R1][L2,R2]拆分成两个,L1-1, [L2,R2]和 R1,[L2,R2].x, [L2,R2]表示起点 L <= x,终点 R满足 L2 <= R <= R2的线段条数,则每个询问的答案就是 R1,[L2,R2]的值 - L…
题意 平面上有\(n\)个点,如果两个点的线段与\(x\)轴的角在\([-45^{\circ}, 45^{\circ}]\),则两个点可以连线.求最少的折线(折线由线段首尾相连)使得覆盖所有点. 分析 bzoj的题面有坑,不是15而是45. 将点绕原点旋转\(-45^{\circ}\)后,能连线的话就是另一个点在左上角.那么问题就是求最少链个数.根据定理,最少链个数=最大反链长度. 题解 用bit求最大反链即可. #include <bits/stdc++.h> using namespace…
题目描述 一个二维平面上有\(n\)个梯形,满足: 所有梯形的下底边在直线\(y=0\)上. 所有梯形的上底边在直线\(y=1\)上. 没有两个点的坐标相同. 你一次可以选择任意多个梯形,必须满足这些梯形两两重叠,然后删掉这些梯形. 问你最少几次可以删掉所有梯形. \(n\leq {10}^5\) 题解 先把坐标离散化. 定义\(A\)为所有梯形组成的集合. 我们定义\(A\)上的严格偏序:两个梯形\(a<b\)当且仅当\(a\)与\(b\)不重叠且\(a\)在\(b\)的左边. 那么每次删掉的…
On the number axis, there are N lines. The two endpoints L and R of each line are integer. Give you M queries, each query contains two intervals: [L1,R1] and [L2,R2], can you count how many lines satisfy this property: L1≤L≤R1 and L2≤R≤R2? Input Firs…
4105.   Lines Counting Time Limit: 2.0 Seconds   Memory Limit: 150000K Total Runs: 152   Accepted Runs: 47 On the number axis, there are N lines. The two endpoints L and R of each line are integer. Give you M queries, each query contains two interval…
                              Defense Lines After the last war devastated your country, you - as the king of the land of Ardenia - decided it washigh time to improve the defense of your capital city. A part of your fortification is a line of magetower…
Nlogonia is fighting a ruthless war against the neighboring country of Cubiconia. The Chief General of Nlogonia's Army decided to attack the enemy with a linear formation of soldiers, that would advance together until conquering the neighboring count…
题目链接: C. Subsequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is…