HDU - 6203 ping ping ping LCA倍增演算法+dfs序+線段樹

來源:互聯網
上載者:User

ping ping ping   HDU - 6203


The structure of the computer room in Northeastern University is pretty miraculous. There are  n servers, some servers connect to the gateway whose IP address is 0 directly. All servers are connected with each other by  n netting twines. It is said that this structure is favorable for maintaining physical problem of servers. 
But because of an unexpected rainstorm, the computer room was destroyed by a terrible thunderclap! 
Our maintainer Bittersweet found that many servers were not able to be visited, so he hurried to the computer room to lookup the reason. After several hours, Bittersweet realized that some net gape of servers were broken by thunderclap. However, there were too many servers to find out all the broken net gapes quickly. So he came up with an idea to assess the damaged condition roughly. Bittersweet decided to turn on some servers and ping other servers randomly, then record the unsuccessful pairs of servers. 
Now he need a program to analyze the record to confirm what is the  minimum      number of servers whose net gape was destroyed by thunderclap. Can you help him to complete this work? 
InputThere are at most 20 test cases. 
In each test case, the first line is an integer  n ( 3≤n≤104              , denoting the number of servers. The IP address of these servers is  1…n     . 
Then follows  n lines, each line contains two integers  u   and  v  ( 0≤u,v≤n               ), denoting that the server whose IP address is  u is connected with the server whose IP address is  v by netting twine initially. 
After those, there is one line contains only an integer  p ( p≤50000            ), denoting the number that Bittersweet uses ping. 
Then follows  p lines, each line contains two integers  U and  V , denoting when using server  U to ping server  V, it returned unsuccessful. 
OutputA single integer  xx in a line, denoting at least 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.