タイトルの説明:
無方向図とその中のすべてのエッジを与えて、この図がすべての頂点が連通しているかどうかを判断します.
入力:
各データ群の最初の行は2つの整数nとm(0<=n<=1000)である.nは図の頂点数を表し、mは図中の辺の数を表す.nが0であると入力が終了する.その後、m行のデータがあり、各行に2つの値xとy(0
出力:
入力データのセットごとに、すべての頂点が接続されている場合は「YES」、そうでない場合は「NO」が出力されます.
サンプル入力:
4 3 1 2 2 3 3 2 2 1 2 3 0サンプル出力:
NO
YES
#include
#include
#include
#include
#include
#include
#include
クラスを使ったほうがいいです.そうしないと、各ケースは内容を再リセットし、データが外に露出し、不快になります.