《POJ1631Bridgingsignals解题报告》由会员分享,可在线阅读,更多相关《POJ1631Bridgingsignals解题报告(4页珍藏版)》请在金锄头文库上搜索。
1、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 com
2、pletely, 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
3、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 th
4、ere 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 sign
5、al 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 conn
6、ecting 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);