博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电1950--Bridging signals (二分法→ →LIS)
阅读量:6582 次
发布时间:2019-06-24

本文共 3175 字,大约阅读时间需要 10 分钟。

Bridging signals

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

Total Submission(s): 971    Accepted Submission(s): 634

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

 

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
4
6
4
2
6
3
1
5
10
2
3
4
5
6
7
8
9
10
1
8
8
7
6
5
4
3
2
1
9
5
8
9
2
3
1
7
4
6
 

 

Sample Output
3
9
1
4
 

 

Source
 

 

Recommend
wangye   |   We have carefully selected several similar problems for you:            
 
 
//函数lower_bound()在first和last中的
前闭后开区间进行二分查找,返回大于或等于val的
第一个元素位置。如果所有元素都小于val,则返回
last的位置(可以越界);**返回值是地址**
num = {10, 3, 2, 50}  
              插入1→ →lower_bound(num, num+3, 1) = 0   ;
              插入60→ →lower_bound(num, num+3, 60) = 4;
思路: 找最长递增子序列。
1 #include 
2 #include
3 using namespace std; 4 int num[40040]; 5 int main() 6 { 7 int i, n, p; 8 scanf("%d", &n); 9 while(n--)10 {11 scanf("%d", &p);12 scanf("%d", &num[0]);13 int m , top = 1;14 for(i=1; i

 

转载于:https://www.cnblogs.com/soTired/p/4688934.html

你可能感兴趣的文章
IT十八掌作业_java基础第五天_静态代码块、类的继承和接口
查看>>
流程控制-for序列、流程控制-for字典
查看>>
Easy APNs Provider的使用
查看>>
多个AsynceTask无法同时运行的现象分析
查看>>
搭建mysql集群
查看>>
职场生存|与努力同样重要的是,学会做好这 6 点!
查看>>
Gson工具包使用
查看>>
有一个系统修复处于挂起状态,需要重新启动才能完成该修复
查看>>
Ubuntu上安装bind9
查看>>
访问共享提示“服务器存储空间不足,无法处理此命令。”
查看>>
C#读写XML文件
查看>>
linux
查看>>
今夜杂谈
查看>>
第七章 虚拟化 虚拟机备份 Veeam backup &Replication
查看>>
微软云计算介绍与实践(介绍之五)
查看>>
在linux下搭建HA和LB集群(lvs&heartbeat群集)
查看>>
安装wine
查看>>
阻抗匹配与史密斯(Smith)圆图基本原理
查看>>
路由器与交换机的密码恢复
查看>>
Cisco路由器上的IPSec协议(站点到站点的×××)
查看>>