luogu#P8056. C 图上的数

C 图上的数

Problem Description

You are given an undirected graph with nn vertices and mm edges (guaranteed to have no multiple edges and no self-loops, but not guaranteed to be connected). Each edge has a distinct ID from 11 to mm.

An edge is defined as an isolated edge if and only if both of its endpoints have already been deleted.

You need to provide an order of deleting vertices. Let PiP_i be the ID of the ii-th edge that becomes an isolated edge. You need to minimize the lexicographic order of PiP_i.

If at some moment multiple edges become isolated edges, we consider that the edge with the smaller ID becomes isolated first.

Input Format

The first line contains two positive integers n,mn, m, representing the number of vertices and edges in the graph.

Lines 22 to m+1m+1: the ii-th line contains two positive integers x,yx, y, representing the two endpoints of the edge with ID i1i-1.

Output Format

To reduce the output size, output i=1mi×Pi\bigoplus\limits_{i=1}^{m} i\times P_i, where \bigoplus denotes bitwise XOR in binary.

6 8
1 2
4 5
6 3
5 2
3 4
5 1
1 4
3 5
44

Hint

[Sample Explanation #1]

The array PP is {1,3,4,6,8,2,5,7}\{1,3,4,6,8,2,5,7\}.

[Constraints]

This problem uses bundled testdata.

All testdata satisfies 1n1061\le n\le 10^6, 1mmin(106,n(n1)2)1\le m\le \min (10^6,\frac{n(n-1)}{2}). The detailed constraints are as follows:

  • Subtask #1 (12 pts): n,m10n, m\le 10.
  • Subtask #2 (17 pts): n,m100n, m\le 100.
  • Subtask #3 (11 pts): n,m5×103n, m\le 5\times 10^3.
  • Subtask #4 (18 pts): m=n1m=n-1, the graph is connected, and the degree of every vertex is at most 22.
  • Subtask #5 (16 pts): m=n(n1)2m=\dfrac{n(n-1)}{2}.
  • Subtask #6 (15 pts): n,m105n, m\le 10^5.
  • Subtask #7 (11 pts): No additional constraints.

Translated by ChatGPT 5