CodeforcesRound #286 (Div.2) D.

Source: Internet
Author: User
ShusekiKingdomistheworldsleadingnationforinnovationandtechnology. Therearencitiesinthekingdom, numberedfrom1ton. ThankstoMr. Kitayutasresearch, role

Shuseki Kingdom is the world's leading nation for innovation and technology. there are n cities in the kingdom, numbered from 1 to n. thanks to Mr. kitayuta's research, it has finally become possible to construct teleportation pipes betwe

Shuseki Kingdom is the world's leading nation for innovation and technology. There areNCities in the kingdom, numbered from 1N.

Thanks to Mr. Sort's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, that is, a teleportation pipe from cityXTo cityYCannot be used to travel from cityYTo cityX. The transportation within each city is extremely developed, therefore if a pipe from cityXTo cityYAnd a pipe from cityYTo cityZAre both constructed, people will be able to travel from cityXTo cityZInstantly.

Mr. Kitayuta is also involved in national politics. He considers that the transportation betweenMPairs of city (AI,?BI) (1? ≤?I? ≤?M) Is important. He is planning to construct teleportation pipes so that for each important pair (AI,?BI), It will be possible to travel from cityAITo cityBIBy using one or more teleportation pipes (but not necessarily from cityBITo cityAI). Find the minimum number of teleportation pipes that need to be constructed. So far, no teleportation pipe has been constructed, and there is no other valid tive transportation between cities.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.