Don't know how to solve this, and pls share your intuition. ty.

Revision en2, by lutha, 2022-11-18 18:14:44

LINK- https://lightoj.com/contest/code-samurai-2022-preliminary/arena/problem/2353

i'm not sure if link is accessible, so i'm putting problem here. any help is very welcomed, because for u its tiny but for me its huge

Ajobdesh is so advanced in its transportation system that there is a road built between every pair of her N cities. Unfortunately, not all of them are kept open all the time. The traffic police reign supreme and decides which roads to keep open and which ones to close. Even though the Ajob Road Transportation Corporation (ARTC) built a lot of roads, the citizens still have to suffer traffic jams every day.

Every day, the traffic police select a city, close down all the open roads and open up all the closed roads between that city and every other city.

After observing this pattern while stuck at a traffic light, you have been wondering whether one day it would be possible that every road between every pair of cities gets opened up.

Input-----

The first line of input contains the integer N (2 ≤ N ≤ 1000), the number of cities. The cities are labeled with numbers from 1 to N.

The second line contains the integer M (0 ≤ M < N*(N-1)/2), the number of currently opened roads. Each of the following M lines contains two different numbers, the labels of the cities that are currently connected.

Output-------

Print a line containing YES if it is possible to have open roads betweem all pairs of cities. Print NO otherwise.

Sample------

Input 3 2 1 2 2 3 Output---- NO

Sample Input 4 2 1 3 2 4 Output---- YES

Notes---- Explanation of the 2nd input file: They first chose city 1. It open roads 1-2, 1-4, but closes 1-3. Then they chose city 3. It opens 3-1, 3-2, 3-4. The city already has 2-4 open, thus opening a road between every pairs of cities.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English lutha 2022-11-18 18:14:44 60
en1 English lutha 2022-11-18 18:13:21 1858 Initial revision (published)