不能交叉的引脚

  (这一题的难度在于读题)题目大意:有一堆引脚(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. Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError

    SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackO ...

  2. Notions of Flow Networks and Flows

    这篇随笔是对算法导论(Introduction to Algorithms, 3rd. Ed.)第26章 Maximum Flow的摘录. ------------------------------ ...

  3. Jquery easyui datagrid 删除多行问题

    http://www.cnblogs.com/Dtscal/archive/2012/07/04/2576639.html 最近模仿了刘冬大哥的<开源框架完美组合之Spring.NET + NH ...

  4. shell与变量的声明的操作

    1.给命令起别名:alias 执行下面命令后,可以使用dir代替ls –l 命令,显示目录中的文件详细信息: 还可以用一个别名表示几个命令 的结合: 2.ps:显示当前登录会话的所有活动进程: 3.更 ...

  5. JS 瀑布流布局

    瀑布流布局 HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"> &l ...

  6. Assembly文件被锁定

    使用 Assembly.LoadFile 加载程序集后 ,被加载的文件就会被锁定,之后就不能对其执行转移.删除等操作 为了解决次问题,我们可以先读取成字节流,然后转换成Assembly.代码如下:复制 ...

  7. sqlmap注入检测

    1.列出可利用数据库: sqlmap  -u  url  --dbs 2.列出某个数据库中表: sqlmap  -u  url   --tables  -D  south sqlmap  -u  ur ...

  8. visual studio 2010 破解版 破解方法

    1.Microsoft Visual Studio 2010下载(均来自微软官网) 高级版(Premium) [建议下载]       http://download.microsoft.com/do ...

  9. PDP 有多种定义,具体哪一种还需研究!!!!

    PDP (用户面进行隧道转发的信息的保存协议) 编辑 本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧! 即PDP上下文,保存用户面进行隧道转发的所有信息,包括RNC/GGSN的 ...

  10. Altera的几个常用的Synthesis attributes

    各厂商综合工具,对HDL综合时都定义了一些综合属性这些属性可指定a declaration,a module item,a statement, or a port connection 不同的综合方 ...