资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
POJ 1631 Bridging signalsTimeTime Limit:Limit: 1000MSMemoryMemory Limit:Limit: 10000K TotalTotal Submissions:Submissions: 10489 Accepted:Accepted: 5761 Description Oh no, theyve 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.InputOn 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 #include #include #include #define maxn 1000100 #define CLR(x) memset(x,0,sizeof(x) using namespace std; int amaxn,dpmaxn; const int INF=(131-1); int main() int t,n;scanf(“%d“,while(t-)scanf(“%d“,for(int i=0;in;i+)scanf(“%d“,fill(dp,dp+n,INF);for(int i=0;in;i+)*lower_bound(dp,dp+n,ai)=ai;printf(“%dn“,lower_bound(dp,dp+n,INF)-dp);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号