# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

A country named **Mueawin** has one or more villages and one or more people live in every village. Two people live in the same village if they are connected i.e. if it is possible to go from one’s home to others.**In this country, a man called happy if he/she has h or more units of money.**

By sharing money, is it possible to make happy all of a village ?

The king of this country wants to know how many villages in his country and how many happy and not happy village in his country. He also wants to know in what kind of village the i^{th} people live. Can you inform the king?

Note that, Here we are just dealing with the integer part of the value, 10% of any amount.

For example, 10% of 365 is:

=> 365 × 10%

=> 365 × ^{10}⁄_{100}

=> 36.5

The integer part of 36.5 is 36. So the 10% of 365 = 36.

The first line of the input contains two positive integers **n** (1 ≤ n ≤ 10^{5}) and **m** (1 ≤ q ≤ 2 × 10^{5}) — The number of people in the country and the number of relations between each other.

The next line contains **n** positive integers *am*_{1}, *am*_{2}, *am*_{3} … *am*_{n}, the initial amount of the **n** people where *am*_{i} (1 ≤ *am*_{i} ≤ 10^{6}) is the initial amount of the i^{th} person.

The next line also contains **n** positive integers *h*_{1}, *h*_{2}, *h*_{3} … *h*_{n}, where *h*_{i} (1 ≤ *h*_{i} ≤ 10^{6}) is the minimum amount to become the i^{th} person happy.

Each of the next **m** lines will contain two positive integers **u** and **v** (1 ≤ u, v ≤ n, u != v), which means two people numbered with **u** and **v** are connected with each other.

Print the **total number of village**, the **number of happy village** and the **number of not happy village** separating by space.
In the next line print n integers with values 0 or 1. If i^{th} people live in the happy village then print 1 otherwise print 0.

Input | Output |
---|---|

5 3 1200 1300 14000 30000 2900 3000 3000 3000 3000 3000 1 3 2 4 3 4 | 2 1 1 1 1 1 1 0 |

The configuration of the country. |

Input | Output |
---|---|

3 3 1 2 3 2 3 1 1 2 2 3 3 1 | 1 0 1 0 0 0 |

92% Solution Ratio

jisan047Earliest,

jisan047Fastest, 0.0s

naimulhasanLightest, 1.7 MB

mijanurShortest, 1076B

Login to submit