Giter VIP home page Giter VIP logo

finding-connections's Introduction

Finding-Connections

The communication network at a given bank is composed of several departmental networks, each of which connects to the remaining networks only through a server. This network topology was chosen for security reasons. All critical data sent between departmental networks are stored on the hard disk of these servers in order to be analysed by automatic filtering tools. In case of a security breach at a given department, the contents of the server's hard disk are instantaneously moved to another departmental server and the local network becomes disconnected from the remaining networks.

Unfortunately, the current network cables do not support fast copies between servers. In order to improve this situation, the IT department is analysing several possibilities to add a faster cable that only connects these servers. One option is to directly connect all pairs of servers by cable, which is extremely fast, but expensive. The other option is to use a tree topology, which is cheaper but also slower.
This is where you come in. You are doing an intership at the IT department and you have to implement a program that, given a map of the complete communication network at the Bank, it locates all departmental servers and computes the amount of cable that is required for both options. In order to be cost effective, you have to consider the least amount of cable and use the current infrastruture, that is, the new cable will go through the buildings side-by-side with the old cable, possibly passing near other network equipment.

Since you do not know what to expect from the data, your program should be prepared to handle strange cases: there is no server, or there a single server and therefore, there is no need to buy new cable; some parts of the network may be completely isolated, but they may contain servers, for which the new cable should also be installed among them - to cut expenses, no connection with servers from the main communication network is required.

Input

The first line of each test case gives the amount of network equipment (n โ‰ค 1000) at the communication network. Note that some nodes of this network may be servers, but you do not know which ones. Then, the next lines provide information about the network infrastructure. Each line contains a pair of positive integers that correspond to the internal id of the network equipment that is directly connected with the existing cable, followed by the length of this cable, as a positive integer value. Each test case terminates with number 0. Then, other test cases may follow.

Output

For each test case, print the number of servers, the total amount of cable for the case of a fully connected network and the total amount of cable for a tree topology, as required by the IT department. If there is no server, report "no server".

finding-connections's People

Contributors

raquel-f avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.