#P5085. 大奔的方案

大奔的方案

Description

If A and B are friends, and B and C are also friends, then A, B, and C are all in the same gang.

Now you are given xx brotherhood relations. Please determine the gang relationships, and then find the new method for nn pirates to split mm coins.

Warning: toxic problem.

Of course, you still need to ensure that pirates with smaller numbers receive as many coins as possible, even if it breaks relationships between gangs. (Figure it out yourself.)

Input Format

The first line contains five integers n,m,p,x,kn, m, p, x, k separated by spaces, representing the number of pirates, the number of coins, the minimum approval percentage, the total number of brotherhood relations, and the so-called friendship cost.

The next XX lines each contain two integers i,ji, j, meaning ii and jj have a brotherhood relation (that is, they are in the same gang).

Output Format

Only one line containing NN integers separated by spaces, representing the final result.

If a pirate dies, output 1-1 instead.

5 7 50 2 1
1 2
3 2
5 1 1 0 0

Hint

Constraints and Notes

For 100%100\% of the testdata: 1n10001\le n\le 1000, 0m1050\le m\le 10^5, 1p1001\le p\le 100, 1x5001\le x\le 500, 1k1001\le k\le 100.

Translated by ChatGPT 5