7055.School Excursion

Time Limit: 1s Memory Limit: 512MB

A group of $n$ children are coming to Helsinki. There are two possible attractions: a child can visit either Korkeasaari (zoo) or Linnanmäki (amusement park).

There are $m$ pairs of children who want to visit the same attraction. Your task is to find all possible alternatives for the number of children that will visit Korkeasaari. The children's wishes have to be taken into account.

Input Format(From the terminal/stdin)

The first input line has two integers $n$ and $m$ : the number of children and their wishes. The children are numbered $1,2,\dots,n$ .

After this, there are $m$ lines describing the children's wishes. Each line has two integers $a$ and $b$ : children $a$ and $b$ want to visit the same attraction.

  • $1 \le n \le 10^5$
  • $0 \le m \le 10^5$
  • $1 \le a,b \le n$

Output Format(To the terminal/stdout)

Print a bit string of length $n$ where a one-bit at index $i$ indicates that it is possible that exactly $i$ children visit Korkeasaari (the bit string is to be considered one-indexed).

Sample Input

Copy
5 3
1 2
2 3
1 5
 · \n
 · \n
 · \n
 · \n

Sample Output

Copy
10011
     \n

The number of children visiting Korkeasaari can be $1$ , $4$ or $5$ .

Source: CSES, Additional Problems II, 1706

Submit

请先 登录

© 2025 FAQs