I - Hospital Lines


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

In hospitals, lines are often drawn on the floor in various directions to help guide visitors to different areas. One day, while Amin was waiting outside the operating room, he started thinking about this:

Suppose there are nn departments in a hospital connected by corridors, forming a layout that can be represented as an undirected, connected graph with nn vertices and mm edges.

Amin wants to color each edge in this graph with one of two colors, red or blue, so that for any two departments (vertices), one can follow a continuous path of edges of same color to travel between them.

This means that if someone wants to travel from department vv to department uu, first we could guide them “follow red” or “follow blue”.

The question Amin faces is: can we color edges of the graph in such a way that any two vertices can be reached using a guide like "follow red/blue"?

ورودی🔗

The first line of input contains an integer tt representing the number of test cases.

1t1051 \leq t \leq 10^5

For each test case, the first line contains two positive integers nn and mm, representing the number of vertices and edges.

2n1052 \leq n \leq 10^5 1m1051 \leq m \leq 10^5 m106 \sum m \leq 10^6

In the next mm lines, each line contains two integers uu and vv, indicating the existence of an edge uvuv in the graph.

1u,vn1 \leq u, v \leq n

It is guaranteed that the given graphs are simple and connected.

خروجی🔗

If there is such coloring print YES; otherwise print NO.

مثال‌ها🔗

ورودی نمونه ۱🔗

3
4 3
1 2
1 3
1 4
2 1
1 2
3 3
1 2
2 3
1 3
Plain text

خروجی نمونه ۱🔗

NO
YES
NO
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.