【hdu 1950】 Bridging signals(LIS模板题)
来源:互联网 发布:淘宝话费充值软件 编辑:程序博客网 时间:2024/06/03 17:21
Bridging signals
'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports of two functional blocks cross each other all over the place. At this late stage of the process, it is too
expensive to redo the routing. Instead, the engineers have to bridge the signals, using the third dimension, so that no two signals cross. However, bridging is a complicated operation, and thus it is desirable to bridge as few signals as possible. The call for a computer program that finds the maximum number of signals which may be connected on the silicon surface without rossing each other, is imminent. Bearing in mind that there may be housands of signal ports at the boundary of a functional block, the problem asks quite a lot of the programmer. Are you up to the task?
Figure 1. To the left: The two blocks' ports and their signal mapping (4,2,6,3,1,5). To the right: At most three signals may be routed on the silicon surface without crossing each other. The dashed signals must be bridged.
A typical situation is schematically depicted in figure 1. The ports of the two functional blocks are numbered from 1 to p, from top to bottom. The signal mapping is described by a permutation of the numbers 1 to p in the form of a list of p unique numbers in the range 1 to p, in which the i:th number pecifies which port on the right side should be connected to the i:th port on the left side.
Two signals cross if and only if the straight lines connecting the two ports of each pair do.
expensive to redo the routing. Instead, the engineers have to bridge the signals, using the third dimension, so that no two signals cross. However, bridging is a complicated operation, and thus it is desirable to bridge as few signals as possible. The call for a computer program that finds the maximum number of signals which may be connected on the silicon surface without rossing each other, is imminent. Bearing in mind that there may be housands of signal ports at the boundary of a functional block, the problem asks quite a lot of the programmer. Are you up to the task?
Figure 1. To the left: The two blocks' ports and their signal mapping (4,2,6,3,1,5). To the right: At most three signals may be routed on the silicon surface without crossing each other. The dashed signals must be bridged.
A typical situation is schematically depicted in figure 1. The ports of the two functional blocks are numbered from 1 to p, from top to bottom. The signal mapping is described by a permutation of the numbers 1 to p in the form of a list of p unique numbers in the range 1 to p, in which the i:th number pecifies which port on the right side should be connected to the i:th port on the left side.
Two signals cross if and only if the straight lines connecting the two ports of each pair do.
4642631510234567891018876543219589231746
3914
题目大意:
求出在题目已给出的条件下,可以尽可能的少搭建一些桥的情况,也就是说尽可能多的留下来一些原有的线路。
可以根据题目给出的示例,找出规律,也就是需要求出其最长上升子序列。
代码:
#include<cstdio>#include<algorithm>#include<cstring>#include<stack>#include<queue>#define INF 0x3f3f3f3fusing namespace std;int dp[40005],a[40005];int main(){int t;scanf("%d",&t);while(t--){int n;scanf("%d",&n);for(int i=0;i<n;i++){scanf("%d",&a[i]);dp[i]=INF;}for(int i=0;i<n;i++) *lower_bound(dp,dp+n,a[i])=a[i];printf("%d\n",lower_bound(dp,dp+n,INF)-dp);} return 0;}
阅读全文
0 0
- 【HDU】-1950-Bridging signals(LIS,模板)
- 【hdu 1950】 Bridging signals(LIS模板题)
- 【HDU】1950 - Bridging signals(LIS 经典模板)
- HDU 1950 Bridging signals(LIS)
- HDU 1950 Bridging signals(LIS)
- hdu 1950 Bridging signals (lis)
- HDU 1950 Bridging signals (LIS)
- HDU 1950 - Bridging signals(LIS)
- poj 1631 || hdu 1950 Bridging signals(动态规划:LIS)
- HDU 1950 Bridging signals(O(nlogn)算法LIS)
- POJ 1631 && HDU 1950 Bridging signals(LIS)
- HDU:1950 Bridging signals(LIS-n*logn解法+思维)
- Poj 1631 && Hdu 1950 Bridging signals【LIS】
- hdu 1950 Bridging signals【LIS nlogn】
- HDU Problem 1950 Bridging signals 【LIS】
- HDU 1950 Bridging signals(LIS nlogn)
- HDU-1950 Bridging signals (nlogn求LIS)
- 杭电-1950Bridging signals(LIS)
- HDU1015
- 连续子数组的最大和
- HDU 6060 RXD and dividing (最小斯坦纳树)
- 简介:Spring定时任务的几种实现
- tomcat 远程调试
- 【hdu 1950】 Bridging signals(LIS模板题)
- Address already in use: JVM_Bind <null>:8080问题解决
- ubuntu windows 双系统
- Servlet之Cookie
- 【SpringMVC-001】idea创建SpringMVC项目傻瓜教程
- 程序打成jar包路径不对、找不到配置文件的解决
- 常用的内排序算法的描述和实现
- 51nod-1831 小C的游戏
- X264参数之zerolatency的分析