Chaotic Cables

시간 제한1초메모리 제한1024 MB

요약
n개 정점의 그래프가 어떤 d에 대한 하이퍼큐브 Q_d인지, 즉 이진 주소가 한 비트만 다른 정점끼리 연결된 그래프인지 판별한다.
난이도

어려움10점 중 8점

유형
그래프, BFS, 비트 연산, 구현
정답자
아직 제출이 없습니다

문제

Your friend Claas is in charge of designing the network for the newly constructed computer lab. Aware of the critical importance of efficiency in network design, Claas opted for the sophisticated Binary Access Point Configuration (BAPC) network topology.

A network is classified as a BAPC network precisely if we can assign a binary address of a fixed length to each device within the network, ensuring that:

  1. Devices are connected if and only if their addresses differ in exactly one bit.
  2. Each possible address is assigned to exactly one device.

Claas started out wiring devices together, but as the intricate web of connections began to take shape, doubt crept into his mind. Was the network he painstakingly constructed truly a BAPC network?

Help Claas determine if the network is a BAPC network.

입력

The input consists of:

  • One line with two integers nn and mm (2≤n≤2⋅1052 \le n \le 2\cdot 10^5, 1≤m≤2⋅1051 \le m \le 2\cdot 10^5) the number of devices and the number of wires in the network.
  • mm lines with integers aa and bb (1≤a,b≤n1 \leq a, b \leq n, a≠ba \ne b), indicating that there is a wire between devices aa and bb.

It is guaranteed that each pair of devices is connected by at most one wire.

출력

Output "yes" if the network is a BAPC network. Otherwise, output "no".

예제2

  1. 예제 1

    입력
    4 3
    1 2
    2 3
    1 4
    
    예상 출력
    no
    
  2. 예제 2

    입력
    8 12
    1 2
    6 2
    8 2
    3 1
    1 7
    3 6
    6 5
    3 4
    8 7
    8 5
    7 4
    5 4
    
    예상 출력
    yes