青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 87  文章 - 279  trackbacks - 0
<2010年7月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

潛心看書研究!

常用鏈接

留言簿(19)

隨筆分類(81)

文章分類(89)

相冊

ACM OJ

My friends

搜索

  •  

積分與排名

  • 積分 - 220442
  • 排名 - 118

最新評論

閱讀排行榜

評論排行榜

解題報告:http://www.mydrs.org/program/list.asp?id=583

Bridging Signals

Time limit: 1 Seconds?? Memory limit: 32768K??
Total Submit: 946?? Accepted Submit: 495??

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

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 ith number specifies which port on the right side should be connected to the ith 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 ith line is the port number of the block on the right side which should be connected to the ith 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

#include? < iostream>
using
? namespace?std;

const ? int ?MAXN? = ? 40001;

void?Solve()
{
????
int?n;
????
int?i,?j,?k;
????
int?l,?r,?m;
????
int?t;
????
int ?d[MAXN]? = ? { 0 };
????
int?a[MAXN];
????
int ?len? = ? 0;
????scanf(
" %d " ,? &n);
????
for ?(i = 1 ;?i <= n;?i ++)?
????????scanf(
" %d " ,? &a[i]);
????
for ?(i = 1 ;?i <= n;?i ++)
????
{
????????
if ?(a[i]? >?d[len])
????????
{
????????????len?
+= ? 1;
????????????d[len]?
=?a[i];
????????}

????????
else
????????
{
????????????l?
= ? 1;
????????????r?
=?len;
????????????
while ?(l? < ?r? - ? 1)
????????????
{
????????????????m?
= ?(l? + ?r)? / ? 2;
????????????????
if ?(d[m]? <?a[i])
????????????????????l?
=?m;
????????????????else
????????????????????r?
=?m;
????????????}

????????????if
?(d[l]?>?a[i])?
????????????????d[l]?
=?a[i];
????????????else
????????????????d[r]?
=?a[i];
????????}

????}

????printf("
%d\n ",?len);????????
}



int?main()
{
????
int?caseTime;
????scanf(
" %d " ,? &caseTime);
????
while ?(caseTime -- ? != ? 0)
????
{
????????Solve();
????}

????system("pause
");
????
return ?0;
}






posted on 2006-10-04 12:20 閱讀(600) 評論(0)  編輯 收藏 引用 所屬分類: ACM題目
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲在线免费视频| 国产欧美亚洲视频| 亚洲午夜极品| 亚洲一二三区精品| 亚洲欧美视频一区二区三区| 亚洲影音一区| 久久综合电影| 久久久久高清| 巨胸喷奶水www久久久免费动漫| 久久久天天操| 欧美激情综合色| 欧美日韩综合久久| 国产麻豆精品视频| 在线成人中文字幕| 亚洲精品一品区二品区三品区| 亚洲国内高清视频| 亚洲一区亚洲| 久久天堂成人| 亚洲精品一区在线| 欧美一区网站| 欧美精品一区视频| 国产女精品视频网站免费| 亚洲精品久久久久久久久久久| 欧美福利网址| 久久国产主播精品| 久久天天躁狠狠躁夜夜av| 狂野欧美激情性xxxx欧美| 亚洲国产乱码最新视频| 亚洲区一区二区三区| 午夜亚洲福利在线老司机| 蜜桃av噜噜一区| 国产精品一区二区三区成人| 一区在线观看视频| 亚洲欧美成人| 欧美黑人在线观看| 亚洲综合色网站| 欧美激情a∨在线视频播放| 国产亚洲欧美一区二区| 一本色道久久综合亚洲精品不卡 | 亚洲视频日本| 久久久久91| 亚洲午夜精品一区二区三区他趣 | 99re热这里只有精品视频 | 亚洲国产精品成人va在线观看| 午夜精品电影| 欧美丝袜一区二区三区| 亚洲黄色精品| 久久一二三区| 午夜精品美女久久久久av福利| 欧美日韩在线影院| 日韩亚洲欧美成人| 欧美国产综合视频| 久久亚洲综合色| 国产一区美女| 亚洲神马久久| 亚洲免费一区二区| 91久久在线视频| 免费试看一区| 亚洲欧洲在线播放| 欧美成人精品在线| 欧美一区二区三区精品| 日韩一级大片在线| 亚洲亚洲精品三区日韩精品在线视频| 模特精品裸拍一区| 久久久www成人免费无遮挡大片| 国产精品久久久久免费a∨大胸| 一区二区欧美在线观看| 亚洲高清不卡av| 噜噜噜91成人网| 亚洲欧洲一区| 亚洲黄色在线视频| 欧美伦理91| 亚洲视频在线播放| 亚洲视频图片小说| 国产欧美短视频| 久久久久国产精品一区| 久久精品国产亚洲aⅴ| 在线观看亚洲a| 欧美成人69av| 欧美福利视频| 亚洲系列中文字幕| 午夜精品久久久久久99热| 国产综合一区二区| 欧美激情亚洲国产| 欧美日韩一区二区国产| 亚洲欧美日韩国产中文| 久久精品系列| 日韩亚洲欧美精品| 亚洲一区二区久久| 狠狠久久亚洲欧美专区| 亚洲福利在线视频| 国产精品国产三级国产| 久久久久久久久久久久久女国产乱 | 最新日韩在线视频| 亚洲神马久久| 在线欧美三区| 在线一区欧美| 亚洲福利视频二区| 亚洲午夜av电影| 亚洲承认在线| 亚洲免费在线视频| 亚洲黄页视频免费观看| 亚洲在线一区| 亚洲老板91色精品久久| 亚洲自拍16p| 亚洲精品久久| 久久精品人人做人人爽| 亚洲私人影院在线观看| 老鸭窝91久久精品色噜噜导演| 午夜精品久久久久久久久久久| 免费视频一区| 六月婷婷一区| 国产无一区二区| 亚洲视频1区2区| 亚洲欧洲在线看| 久久国产欧美| 狠狠色丁香婷婷综合影院| 亚洲电影欧美电影有声小说| 国产精品家庭影院| 欧美高清视频在线观看| 国产一区二区在线观看免费播放| 一本一本久久a久久精品综合妖精| 伊人久久婷婷| 欧美在线免费观看| 性欧美办公室18xxxxhd| 欧美精品在线播放| 欧美粗暴jizz性欧美20| 国产在线国偷精品产拍免费yy| 99国产精品久久久久老师| 最新中文字幕亚洲| 免费影视亚洲| 欧美激情第六页| 亚洲高清色综合| 久久久久久久97| 久久久伊人欧美| 国产在线播放一区二区三区| 欧美在线电影| 久久综合伊人| 亚洲黄色一区| 欧美高清视频在线观看| 亚洲国产精品成人一区二区| 91久久黄色| 欧美激情一区二区久久久| 欧美国产日产韩国视频| 亚洲国产日韩综合一区| 免费成人高清在线视频| 亚洲国产欧美一区二区三区丁香婷| 亚洲第一中文字幕在线观看| 免费观看国产成人| 亚洲盗摄视频| 一区二区三区久久精品| 欧美日韩精品一本二本三本| 日韩视频免费在线观看| 亚洲欧美国产一区二区三区| 国产精品欧美日韩| 久久精品欧美日韩| 亚洲高清在线观看一区| 夜夜嗨av一区二区三区四区 | 亚洲第一福利视频| 99re66热这里只有精品4| 欧美日韩另类视频| 亚洲性视频h| 久久精品首页| 亚洲肉体裸体xxxx137| 欧美视频中文一区二区三区在线观看 | 久久综合伊人77777蜜臀| 亚洲国产一区二区a毛片| 欧美日本韩国在线| 亚洲一区二区影院| 蜜桃精品久久久久久久免费影院| 亚洲毛片播放| 国产免费观看久久黄| 老司机午夜精品视频在线观看| 日韩天堂在线视频| 久久一区二区三区av| 亚洲视频每日更新| 一区在线观看视频| 欧美天堂亚洲电影院在线观看 | 久久天天综合| 日韩视频一区二区| 国产日韩欧美自拍| 欧美二区视频| 香蕉久久夜色精品国产使用方法| 欧美激情成人在线视频| 久久精品国产99国产精品| 亚洲人成亚洲人成在线观看图片| 国产精品美女久久久| 蜜桃久久精品一区二区| 亚洲伊人第一页| 亚洲国产欧美在线人成| 久久精品国产亚洲精品| 亚洲一区欧美二区| 亚洲精品视频免费观看| 国模 一区 二区 三区| 欧美日一区二区在线观看| 久久久精品国产免费观看同学| 亚洲午夜久久久久久尤物 | 欧美成人中文字幕在线| 午夜精品久久久久久久| 一本久道久久综合狠狠爱|