hdu----(1950)Bridging signals(最长递增子序列 (LIS) )
2014-09-24 21:43
459 查看
Bridging signals
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 667 Accepted Submission(s): 443
[align=left]Problem Description[/align]
'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?
//#define LOCAL #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #define inf 0x3f3f3f3f using namespace std; const int maxn=40005; int str[maxn],ans[maxn],dp[maxn]; int n,dd; int LIS(int a[], int n) { int i, j,res=0; for(i=1;i<=n;i++) ans[i]=inf; memset(dp,0,sizeof(int)*(n+1)); for(i=1;i<=n;++i) { dp[i]=lower_bound(ans+1,ans+n+1,a[i])-ans; // j=bsearch(c, size, a[i]); //在已有的序列中进行替换 if(res<dp[i])res=dp[i]; j=i; if(j>0&&ans[dp[j]]>a[j]) ans[dp[j]]=a[j]; } return res; } int main() { #ifdef LOCAL freopen("test.in","r",stdin); #endif int cas; scanf("%d",&cas); while(cas--){ scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",str+i); } printf("%d\n",LIS(str,n)); } return 0; }
View Code
相关文章推荐
- hdu 1087 LIS 最长递增子序列的值
- [LIS_最长递增子序列]-hdu 1087 Super Jumping!
- [LIS_最长递增子序列]-hdu 1003 Max Sum
- hdu 4512(最长公共递增子序列加强版)
- hdu 1087 Super Jumping! Jumping! Jumping!(dp+最长递增序列)
- 编程之美 最长递增子序列 LIS
- lis 最长递增序列
- [ACM] hdu 1025 Constructing Roads In JGShining's Kingdom (最长递增子序列,lower_bound使用)
- 最长递增子序列(LIS)
- 动态规划-最长递增序列(LIS)【模板】
- HDU 4512 吉哥系列故事——完美队形I LCIS 最长递增公共子序列
- 2.16 最长递增子序列 LIS
- LIS 最长有序子序列(递增/递减/非递增/非递减)
- 最长递增子序列(LIS)
- HDU 1257 最少拦截系统 LIS最长不减子序列
- hdu,1025 dp求最长递增序列。
- [zz]最长递增子序列的求法 LIS
- hdu 1069 Monkey and Banana 动态规划(最长递增子序列变形)
- UVa 111 - History Grading 最长递增子序列 LIS
- [ACM] hdu 1025 Constructing Roads In JGShining's Kingdom (最长递增子序列,lower_bound使用)