AtCoder Regular Contest 143
D
Bridges
AtCoder
⌀ 2229
原题
← CE →
翻译中…

Problem Statement

翻译中…

We have two sequences $A_1,\ldots, A_M$ and $B_1,\ldots,B_M$ consisting of intgers between $1$ and $N$ (inclusive).

翻译中…

For a string of length $M$ consisting of 0 and 1, consider the following undirected graph with $2N$ vertices and $(M+N)$ edges corresponding to that string.

翻译中…
  • If the $i$-th character of the string is 0, the $i$-th edge connects Vertex $A_i$ and Vertex $(B_i+N)$.
  • If the $i$-th character of the string is 1, the $i$-th edge connects Vertex $B_i$ and Vertex $(A_i+N)$.
  • The $(j+M)$-th edge connects Vertex $j$ and Vertex $(j+N)$.
翻译中…

Here, $i$ and $j$ are integers such that $1 \leq i \leq M$ and $1 \leq j \leq N$, and the vertices are numbered $1$ to $2N$.

翻译中…

Find one string of length $M$ consisting of 0 and 1 such that the corresponding undirected graph has the minimum number of bridges.

翻译中…

Notes on bridges A bridge is an edge of a graph whose removal increases the number of connected components.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq M \leq 2 \times 10^5$
  • $1 \leq A_i, B_i \leq N$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M
A_1 A_2 \cdots A_M
B_1 B_2 \cdots B_M

翻译中…

Output

翻译中…

Print one string that satisfies the requirement. If there are multiple such strings, you may print any of them.

翻译中…

样例

Input #1
2 2
1 1
2 2
Output #1
01
The graph corresponding to `01` has no bridges. In the graph corresponding to `00`, the edge connecting Vertex $1$ and Vertex $3$ and the edge connecting Vertex $2$ and Vertex $4$ are bridges, so `00` does not satisfy the requirement.
Input #2
6 7
1 1 2 3 4 4 5
2 3 3 4 5 6 6
Output #2
0100010
题目信息
题号
arc143_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。