(二分+dp) poj 1631 Bridging signals

点云入门笔记(一):点云数据及获取 点云概念: 点云是某个坐标系下的点的数据集。点包含了丰富的信息,包括三维坐标 X,Y,Z、颜色、分类值、强度值、时间等等。 阅读详情
Bridging signals
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 5919 Accepted: 3233

Description

'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 crossing each other, is imminent. Bearing in mind that there may be thousands 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?

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 specifies 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.

Input

On the first line of the input, there is a single positive integer n, telling the number of test scenarios to follow. Each test scenario begins with a line containing a single positive integer p < 40000, the number of ports on the two functional blocks. Then follow p lines, describing the signal mapping:On the i:th line is the port number of the block on the right side which should be connected to the i:th port of the block on the left side.

Output

For each test scenario, output one line containing the maximum number of signals which may be routed on the silicon surface without crossing each other.

Sample Input

4642631510234567891018876543219589231746

Sample Output

3914
 
Algorithm:【算法进阶之路】之算法面试刷题集合—数据结构的简介、最强学习路线(逻辑结构【数组-链表-栈和队列/树-图-哈希】、物理结构【元素/关系】、数据运算【十大排序/四大查找-图三大搜索- ​ Algorithm:【算法进阶之路】之算法面试刷题集合—数据结构的简介、最强学习路线(逻辑结构【数组-链表-栈和队列/树-图-哈希】、物理结构【元素/关系】、数据运算【十大排序/四大查找-图三大搜索-树三大遍历】、高级算法【枚举/回溯/递归/分治/动规/贪心】)、问题为导向的十大类刷题算法总结之详细攻略 目录 相关文章 数据结构思维导图 基本术语 一、数据结构的概述 二、数据的逻辑结构 三、数据的物理结构 四、数据的运算 阅读详情

相关推荐

保姆级教程 | MS构建三层石墨后转成LAMMPS的data文件

喜欢的话记得一键三连~

baguette的博客 2951

POJ 1631 Bridging signals

Bridging signalsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 6001 Accepted: 3285DescriptionOh no, theyve done it again, cries the chief designer a

bobten2008的专栏 1030

大华事件检测智能服务器,大华股份:高速公路智能事件检测 解决方案

1方案背景随着我国基础设施建设的飞速发展,公路尤其是高速公路的总里程数年年攀升。交通运输部统计数据显示,截止2017年底全国公路总里程477.35万公里,其中高速公路13.65万公里,位居世界第一。高速公路的运营和管理作为全国交通管理的重要组成部分日益受到严峻挑战,交通拥堵和事故频发已成为高速公路上非常突出的问题。抛洒物、行人、车辆不规则行驶等事件是导致以上结果的重要原因。基于视频分析的高速公路智...

weixin_39523887的博客 1822

HDU1950:Bridging signals(LIS)

Problem Description '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

ACM!荣耀之路! 2964

Alipay 支付唤起 h5 测试

测试地址 https://recharge.apps.oppomobile.com/recharge-center/recharge/?from=message try { //唤起客户端快捷参数 var data = {"requestType":"SafePay","fromAppUrlScheme":"alipays","dataString":"h5_ro...

六桥风月IT随笔 1万+

inferCNVpy分析流程学习

inferCNV的用途大家都已经很清楚了,接下来就走一下流程,试一试Python版的inferCNV。使用的数据集为:GSE188711,既往推文可见:Scanpy分析全流程(含harmonypy整合/细胞周期矫正/双细胞检测及去除)(

zfyyzhys的博客 1294

hdu - 1950 Bridging signals(最长上升序列,dp 二分求法)

'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 ...

obsorb_knowledge的博客 297

Halcon算子知识:optical_flow_mg

光流(Optical Flow)是一种研究图像对齐的算法,一般包括两大类:稀疏光流和稠密光流。稀疏光流就是研究图像中稀疏点的光流,这些点一般是角点;稠密光流则是研究图像中所有点的偏移量。以下介绍halcon的基本光流算子optical_flow_mg的原理方法。该算子计算两个图片的光流法。 二、算子说明 optical_flow_mg(ImageT1, ImageT2 : VectorField : Algorithm, SmoothingSigma, Integration

gongdiwudu的专栏 1万+

Bridging signals(DP)

Description ‘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 connectin

Techay的博客 526

智能工厂评估模型研究

摘要:通过对国内外现有智能制造评估模型的研究,结合重庆制造业行业领跑者与落后者之间差距大的现状,以实现全要素全连接的数字化工厂为出发点,融合工业互联网标识,构建实践可行的智能工厂评估模型推动中小型企业参与智能制造转型,缓和两极分化问题。本评估模型包含工厂体系架构的3个层级,提供用于推动智能制造转型的参考,包括设计、生产、管理的全过程评估。关键词:智能制造评估模型;智能制造转型;全连接工厂;工业互联网标识0 引言受行业需求与技术创新的影响,全球制造业在历经了工业1.0机械化、工业2.0电气化和工业3.0自动

罗伯特技术屋 677

小波变换完全指南:从原理到实践的深度解析

在信号处理领域,傅里叶变换长期以来一直是频域分析的主要工具。然而,傅里叶变换存在一个根本性的局限:它只能告诉我们信号中包含哪些频率成分,却无法告诉我们这些频率成分在什么时刻出现。这就像是你知道一首歌用了哪些音符,却不知道这些音符的演奏顺序。小波变换(Wavelet Transform) 应运而生,它完美地解决了这个问题。小波变换不仅能够提供频率信息,还能同时提供时间信息,实现了信号的时频联合分析。本文将带你从零开始,深入理解小波变换的原理、实现和应用。傅里叶变换的定义如下: 它使用正弦和余弦这样的全局基函数

电脑管家 207

Bridging signals (P1631)

这个是题要用到DP加上树状数组的二分作用时候上才够。 这个题的题意仔细一下就是序列单调上升的问题。也就是以前做过的导弹问题,只是这里的数据比较大。所以O(n*n)会超时。 #include #include #include #include #include #include #include #include #include #include #include

jiangjiashi的博客 565

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Poj 1631 Bridging signals(二分+DP 解 LIS)

题意:题目很难懂,题意很简单,求最长递增子序列LIS。 分析:本题的最大数据40000,多个case。用基础的O(N^2)动态规划求解是超时,采用O(n*log2n)的二分查找加速的改进型DP后AC了。 在基础的动态规划解法中,由于动态规划的无后效性(对于每个阶段来说,它以前的各阶段状态无法直接影响它未来的决策,只能间接地通过当前状态来影响),当我们考察第i+1个元素的时候,我们是不考虑前面i

InkGenius 830

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

poj 1631 Bridging signals (LIS 最长递增子序列 DP-二分)

题目:http://poj.org/problem?id=1631 思路:LIS 最长递增子序列,如果用一般的动态规划算法,复杂度是O(n^2),题目的数据规模下会超时,采用二分的思想:复杂度是O(nlogn) 代码: 首先是一般的DP:  #include #include #include using namespace std; const int MAX=40001; int dp

R_xiaozhu_Q的专栏 1539

[POJ1631]Bridging signals (DP,二分优化)

题目链接:http://poj.org/problem?id=1631   就是求一个LIS,但是范围太大(n≤40000),无法用常规O(n²)的朴素DP算法,这时需要优化。   新加一个数组s[]来维护长度当LIS的长度为len时候需要的数组a中的最小数字的值,可以证明这个数组是严格单调递增的,因此可以二分确定每次枚举到a[i]的时候,a[i]在这个数组中所处的位置(下标),也就是a[i]...

weixin_30938149的博客 78

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

Bridging signals Time Limit:1000MS Memory Limit:10000K Total Submissions:9234 Accepted:5037 Description 'Oh no, they've done it again', cries the chief designe...

diansitao5461的博客 129

POJ 1631 Bridging signals 解题报告(附详细分析)最长上升子序列的dp+二分

这道题是最长上升子序列的问题。 常规思路是用动态规划,时间复杂度是n ^ 2,结果会超时。 思路: input 1 7 3 5 9 4 8 dp[1]=1; 因为7>1 dp[2]=dp[1]+1=2; 因为3>1, 3<7, dp[3]=dp[1]+1=2; 因为5>3, 5 dp[4]=dp[3]+1=3; 因为9>5, dp[5]=dp[4]+1=4; 因为43

Yonah潇的专栏 882

POJ 1631 Bridging signals 最长上升子序列小结 LIS的O(nlogn)算法

POJ 1631 Bridging signals 题目分析: 题目要求避免相交,则可转化为对给定的序列求最长上升子序列。 首先使用了dp来求解,复杂度为O(n*n),在题目的数据范围下超时了… #include<iostream> #include<stdio.h> #include<algorithm> using namespace std; int dp...

RPG_Zero的博客 305

poj 1631 Bridging signals

Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12333   Accepted: 6736 Description 'Oh no, they've done it again', cries the chief designer

Jazz_Charles的博客 444

Bridging signals POJ - 1631

'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 ...

Qtt110的博客 298

[dp]最长递增子序列poj 1631Bridging signals

最长递增子序列

Dafang_Xu的博客 498

POJ1631 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 ...

qq_39479426的博客 220

POJ - 1631 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 ...

GJLfly的博客 246
上一篇: (简单dp 水过) poj 1887 Testing the CATCHER
下一篇: (字典树应用) poj 1451 T9
Hashmat
博客等级 码龄16年 14粉丝 62原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值