CF292B.Network Topology

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.

Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of nn computers, some of them are connected by a cable. The computers are indexed by integers from 11 to nn . It's known that any two computers connected by cable directly or through other computers

Polycarpus decided to find out the network's topology. A network topology is the way of describing the network configuration, the scheme that shows the location and the connections of network devices.

Polycarpus knows three main network topologies: bus, ring and star. A bus is the topology that represents a shared cable with all computers connected with it. In the ring topology the cable connects each computer only with two other ones. A star is the topology where all computers of a network are connected to the single central node.

Let's represent each of these network topologies as a connected non-directed graph. A bus is a connected graph that is the only path, that is, the graph where all nodes are connected with two other ones except for some two nodes that are the beginning and the end of the path. A ring is a connected graph, where all nodes are connected with two other ones. A star is a connected graph, where a single central node is singled out and connected with all other nodes. For clarifications, see the picture.

(1) — bus, (2) — ring, (3) — starYou've got a connected non-directed graph that characterizes the computer network in Polycarpus' corporation. Help him find out, which topology type the given network is. If that is impossible to do, say that the network's topology is unknown.

输入格式

The first line contains two space-separated integers nn and mm (4<=n<=105; 3<=m<=105)(4<=n<=10^{5}; 3<=m<=10^{5}) — the number of nodes and edges in the graph, correspondingly. Next mm lines contain the description of the graph's edges. The ii -th line contains a space-separated pair of integers xix_{i} , yiy_{i} (1<=xi,yi<=n)(1<=x_{i},y_{i}<=n) — the numbers of nodes that are connected by the ii -the edge.

It is guaranteed that the given graph is connected. There is at most one edge between any two nodes. No edge connects a node with itself.

输出格式

In a single line print the network topology name of the given graph. If the answer is the bus, print "bus topology" (without the quotes), if the answer is the ring, print "ring topology" (without the quotes), if the answer is the star, print "star topology" (without the quotes). If no answer fits, print "unknown topology" (without the quotes).

输入输出样例

  • 输入#1

    4 3
    1 2
    2 3
    3 4
    

    输出#1

    bus topology
    
  • 输入#2

    4 4
    1 2
    2 3
    3 4
    4 1
    

    输出#2

    ring topology
    
  • 输入#3

    4 3
    1 2
    1 3
    1 4
    

    输出#3

    star topology
    
  • 输入#4

    4 4
    1 2
    2 3
    3 1
    1 4
    

    输出#4

    unknown topology
    
首页