申請SAE

如果您發現本博客的外觀很難看,那是因為部分外觀文件被中國.國家.防火.牆屏.蔽所致!
請翻~牆!

我的Wordpress博客的地址: http://zhuyf.tk/

2012年2月1日 星期三

Tyvj1721(寒假模擬賽提高組) 島嶼 解題報告

  島嶼 

描述 Description
湖面上有n座島嶼,從1~n編號。現在要湖上建橋使得島嶼連接起來。橋雙向通行。

輸入格式 Input Format
輸入第一行有兩個整數n,m。
接下來是m行,按照時間順序每行是一次詢問。每行第一個整數q代表詢問的內容:如果q=1,則接下來是兩個島嶼編號a,b(a≠b);如果q=2,則接下來是一個島嶼編號c。 

輸出格式 Output Format
對於每個詢問,按次序各輸出一行作爲回答:
q=1時:如果a,b相互可達,則輸出Yes;如果a,b相互不可達,則輸出No,並在a,b之間建一座橋。
q=2時:輸出一個整數x,表示由c出發可以到達的島嶼有x個(不包括c自身)。

2012年1月31日 星期二

[歐拉路]NOIP模擬題:傳送機 sent 解題報告

  【題目描述】
  刷完牙洗完臉,黃黃同學就要上課去了。可是黃黃同學每次去上課時總喜歡把校園裡面的每條路都走一遍,當然,黃黃同學想每條路也只走一遍。我們一般人很可能對一些地圖是辦不到每條路走一遍且僅走一遍的,但是黃黃同學有個傳送機,他可以任意地將一個人從一個路口傳送到任意一個路口。
可是,每傳送一次是需要耗費巨大的內力的,黃黃同學希望可以用最少的傳送次數完成遊遍校園,你能幫助他嗎 ?
因為黃黃同學只是遊歷校園,於是我們可以認為黃黃同學可以從任意點開始,到任意點結束。


[經典算法]字符串的排序 (tyvj 1101)

試題:tyvj 1101  (http://tyvj.cpwz.cn/Problem_Show.asp?id=1101

【題目大意】
給你N(N<=10000)字符串,每個字符串長度小於256,把他們按字典序排序並輸出。

【分析】
C++的快排不是用來吃白飯的~直接調用C++的快排函數,0 ms 無壓力。
為什麼還有很多人會超時啊~




VijosNT Mini 2.0.5.6

#01: Accepted (0ms, 1212KB)
#02: Accepted (0ms, 1036KB)
#03: Accepted (0ms, 1192KB)
#04: Accepted (0ms, 880KB)
#05: Accepted (0ms, 1020KB)
#06: Accepted (0ms, 760KB)
#07: Accepted (0ms, 528KB)
#08: Accepted (0ms, 452KB)
#09: Accepted (0ms, 584KB)
#10: Accepted (0ms, 1084KB)

Accepted / 100 / 0ms / 1212KB

2012年1月30日 星期一

[BFS]POI2007 山峰和山谷 grz 解題報告

Ridges and Valleys

Memory limit: 32 MB

Byteasar loves trekking in the hills. During the hikes he explores all the ridges and valleys in vicinity. Therefore, in order to plan the journey and know how long it will last, he must know the number of ridges and valleys in the area he is going to visit. And you are to help Byteasar.
Byteasar has provided you with a map of the area of his very next expedition. The map is in the shape of a square. For each field belonging to the square (for ), its height is given.
We say two fields are adjacent if they have a common side or a common vertex (i.e. the field is adjacent to the fields , , , , , , , , provided that these fields are on the map).
We say a set of fields forms a ridge (valley) if:
  • all the fields in have the same height,
  • the set forms a connected part of the map (i.e. from any field in it is possible to reach any other field in while moving only between adjacent fields and without leaving the set ),
  • if and the field is adjacent to , then (for a ridge) or (for a valley).
In particular, if all the fields on the map have the same height, they form both a ridge and a valley.
Your task is to determine the number of ridges and valleys for the landscape described by the map.

NOI2007 社交網絡 network 解題報告

【題目描述】 
 懶得貼上試題了~發個連結:NOI2007 Day1試題連結
 【分析】
這是這幾年NOI中最簡單的題了~就是一個多源最短路+乘法原理。 

用Map[i][j]表示i、j之間的最短路徑長度; 
用Path[i][j]表示i、j之間最短路徑的條數(初始化為1)。

 先用Floyd算法求每兩點之間的最短路,鬆弛時要注意,如果出現:
 Map[i][k]+Map[k][j]==Map[i][j] 則說明這又是最短路,所以Path[i][j]+=Path[i][k]*Path[k][j]。
 如果可以鬆弛,即Map[i][k]+Map[k][j]<Map[i][j],則Path[i][j]=Path[i][k]*Path[k][j]即可。

 最後亂搞一個三重循環求I(v),按照題意走即可AC。

2012年1月29日 星期日

[動態規劃]OI練習題:取數字遊戲 number

Title: 取數字遊戲【試題連結
Input: number.in
Output: number.out
Time Limit: 1000 ms
Memory Limit: 128 MB
Level: ★☆
【問題描述】
給定 M*N 的矩陣,其中的每個元素都是 -10 到 10 之間的整數。你的任務是從左上角( 1 , 1 )走到右下角( M , N ),每一步只能向右或向下,並且不能走出矩陣的範圍。你所經過的方格裏面的數字都必須被選取,請找出一條最合適的道路,使得在路上被選取的數字之和是儘可能小的正整數。