不能交叉的引脚

  (这一题的难度在于读题)题目大意:有一堆引脚(signals),左边一排,右边一排,左边从上到下,对应着连接右边的引脚(所有的引脚都被接上),现在引脚之间的连线有交叉,我们要桥接这些交叉,而桥接是费事的,现在要你求不交叉引脚的最大数目

  明白题在说什么以后,是不是感觉豁然开朗?

  没错,这一题我们只用把左边的引脚从上到下排列(事实上已经排了),然后看右边对应的引脚的上升序最长有多少就可以了

  昨天我弄了一个Wooden Sticks,这一题也要用到LIS,而且还是直接用LIS,更简单

 #include <iostream>
#include <functional>
#include <algorithm> using namespace std;
typedef int Position; static int ports[];
static int stacks[]; void Search(const int);
Position Binary_Search(const int,const int); int main(void)
{
int case_sum, ports_sum;
while (~scanf("%d", &case_sum))
{
for (int j = ; j < case_sum; j++)
{
scanf("%d", &ports_sum);
for (int i = ; i < ports_sum; i++)
scanf("%d", &ports[i]);//左边的每一个点对应右边的拿一个点
Search(ports_sum);
}
}
return ;
} Position Binary_Search(const int len,const int item)
{
int left = , right = len, mid; while (left <= right && left != len)
{
mid = (left + right) / ;
if (item < stacks[mid])
right = mid - ;
else
left = mid + ;
}
return left;
} void Search(const int ports_sum)
{
int pos;
int length = ; stacks[] = ports[]; for (int i = ; i < ports_sum; i++)
{
pos = Binary_Search(length,ports[i]); stacks[pos] = ports[i];
if (pos == length)
length++;
}
printf("%d\n", length);
}

DP:Bridging Signals(POJ 1631)的更多相关文章

  1. poj 1631 Bridging signals (二分||DP||最长递增子序列)

    Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9234   Accepted: 5037 ...

  2. OpenJudge/Poj 1631 Bridging signals

    1.链接地址: http://poj.org/problem?id=1631 http://bailian.openjudge.cn/practice/1631 2.题目: Bridging sign ...

  3. POJ 1631 Bridging signals

    Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9441   Accepted: 5166 ...

  4. POJ 1631 Bridging signals(LIS O(nlogn)算法)

    Bridging signals Description 'Oh no, they've done it again', cries the chief designer at the Waferla ...

  5. POJ 1631 Bridging signals(LIS 二分法 高速方法)

    Language: Default Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1076 ...

  6. Bridging signals(二分 二分+stl dp)

    欢迎参加——每周六晚的BestCoder(有米!) Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 6 ...

  7. hdu----(1950)Bridging signals(最长递增子序列 (LIS) )

    Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. B - Bridging signals (LIS)

    点击打开链接 B - Bridging signals 'Oh no, they've done it again', cries the chief designer at the Waferlan ...

  9. hdoj 1950 Bridging signals【二分求最大上升子序列长度】【LIS】

    Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

随机推荐

  1. Emmet

    一.简介 Emmet (前身为 Zen Coding) ,不是软件也不是代码,是编辑器(如sublime text)的插件,相应的后缀文件(.html/.css)输入指定的缩写语法,按下tab键就能生 ...

  2. BZOJ-1625 宝石手镯 01背包(傻逼题)

    傻逼题,懒得打,复制蛋蛋的.. 1625: [Usaco2007 Dec]宝石手镯 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1076 Solved: ...

  3. html,body { margin:0; padding:0;border:0}

    body,html /* 设置窗口DIV为浏览器大小*/ { margin:; padding:; height:100%; } 下面代码 <!DOCTYPE html> <html ...

  4. iOS应用支持IPV6

    一.IPV6-Only支持是啥? 首先IPV6,是对IPV4地址空间的扩充.目前当我们用iOS设备连接上Wifi.4G.3G等网络时,设备被分配的地址均是IPV4地址,但是随着运营商和企业逐渐部署IP ...

  5. NSThread - (void)start vs java Thread implements Runnable

    This method spawns the new thread and invokes the receiver’s main method on the new thread. If you i ...

  6. xml 嵌入式资源

    使用Ibatis总是说未能加载相应的sqlmap.xml,原来是 xml以内容方式,而不是嵌入式方式载入Dll中

  7. javascript中this的学习总结

    在开发中,this多使用在function函数中,也正是由于调用function的对象的不同,才导致了this的指向不同.需要明白(1).function也是对象:(2).function执行时是在某 ...

  8. Silverlight实例教程 - 自定义扩展Validation类,验证框架的总结和建议(转载)

    Silverlight 4 Validation验证实例系列 Silverlight实例教程 - Validation数据验证开篇 Silverlight实例教程 - Validation数据验证基础 ...

  9. JS判断一个数组中是否有重复值的三种方法

    方法一: var s = ary.join(",")+","; for(var i=0;i<ary.length;i++) { if(s.replace( ...

  10. TYVJ2477 架设电话线

    题目描述 Farmer John打算将电话线引到自己的农场,但电信公司并不打算为他提供免费服务.于是,FJ必须为此向电信公司支付一定的费用.     FJ的农场周围分布着N(1 <= N < ...