

Don't know how to solve this, and pls share your intuition. ty.
source link: https://codeforces.com/blog/entry/109175?f0a28=1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.
Recommend
-
44
-
48
-
21
Wondering why deep learning works? Here is the intuition behind it. This blog is wholly inspired by the lectures of Professor...
-
34
In the physical world, nanotechnology predictably brings us surprises. Being structured on nano-scale, the most common materials, such as carbon, iron or copper, gain new unforeseen properties. What we know about them on t...
-
9
Developing Your Intuition For Math Our initial exposure to an idea shapes our intuition. And our intuition impacts how much we enjoy a subject. What do I mean? Suppose we want to define a “cat”: Caveman def...
-
19
Your intuition is correct, and the cold logic is wrongMay 9, 2021For an Nth time, I'm seeing the story of the smartest woman in the world proving eve...
-
8
A problem I made but don't know how to solve A problem I made but don't know how to solve ...
-
7
Designers, use your intuitionWhen collaboration becomes consensus-driven design...
-
12
Nine QuestionsChallenge your intuition with a guessing gameDive into a guessing game where you match inventors to their creations based on looks alone 👨🔬 How good is your gut fe...
-
6
Trusting Your Intuition to Make Design DecisionsBalancing your gut instinct with data-driven design decisions
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK