编程介的小学生 2017-01-23 11:23 采纳率: 20.3%
浏览 943
已采纳

Michelle's Evaluation

Description

After years of toil designing and evaluating varieties of complex networks, Michelle, an elite engineer, has recently made the decision to develop an assistant software to help herself out.

Consider a network built up with undirected water supply pipes each connecting a pair of junctions that supply or consume water. A shortcut of length L is defined as a sequence of L distinct junctions such that two junctions are adjacent in the network if and only if they are adjacent in the sequence. A network is regarded speedy if there is no shortcut with a length greater than three.

Now, please try to work out an efficient solution for Michelle to determine whether a network is speedy or not.

Input

The input contains exactly one test case given as specified below:

Line 1 Two integers N (1 < N < 1,200) and M, which are the numbers of junctions and pipes, respectively.
Line 2 – M + 1 Two integer A and B (1 ≤ A, B ≤ N) on each line, describing a pipe connecting junctions A and B.
You can assume that there exists a path between any two junctions.

Output

Output “Yes” if the network is speedy, otherwise print “No”.

Sample Input

4 4
1 2
2 3
3 4
4 1
Sample Output

Yes

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-01-23 16:27
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗