AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

DAPC24-086.Chaotic Cables

Medium · 1 s · 256 MB

  • icpc
  • dapc
  • 2024

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.

Giriş formatı

The input consists of:

• One line with two integers nnn and mmm (2≤n≤2⋅1052 \le n \le 2\cdot 10^52≤n≤2⋅105, 1≤m≤2⋅1051 \le m \le 2\cdot 10^51≤m≤2⋅105) the number of devices and the number of wires in the network.

• mmm lines with integers aaa and bbb (1≤a,b≤n1 \leq a, b \leq n1≤a,b≤n, a≠ba \ne ba=b), indicating that there is a wire between devices aaa and bbb.

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

Çıxış formatı

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

Qeyd

Source: Delft Algorithm Programming Contest 2024 · Author: Mees de Vries · License: CC BY-SA 4.0 · Original: https://dapc.wisv.ch · Statement adapted for AlgoLens and shared under the same license. · 67 of the 187 original test cases (the largest) are omitted here to keep the problem lightweight.

Nümunələr

Giriş #1

4 3
1 2
2 3
1 4

Çıxış #1

no

Giriş #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

Çıxış #2

yes