can anyone help me out in the below problem solution. I didn't understand the editorial. https://codeforces.net/contest/1286/problem/B
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
can anyone help me out in the below problem solution. I didn't understand the editorial. https://codeforces.net/contest/1286/problem/B
Name |
---|
i dont read the editorial but my solution was that if in the tree a node like v has sz[v] nodes in its subtree if(sz[v] < a[v]) its impossible to reach the goal. else you can give the weights of its subtree nodes a permutation then for a new vertex you can merge its children permutation to make bigger permutation and then for the root you can actully give the nodes the last permutation if you want you can see my soloution in my submissions
can u explain how to merge the children permutation with the parent one
you have the permutation of the children. for example the node v has 3 children with permutation 123, 12, 1234 : so you merge them and get the 123 45 6789 (you make the permutation of its children from 1 -> x : k -> x + k) and then you have the value of its children and you know where you have to put the v value for example if a[v] == 4 : the permutation become 123 4 5 678910 you add the v's value in the permutation
Thanks i did it with a little different update i,e at every time each node get a unused smallest number then i insert parent in the sorted oreder of permutation of childrens and finally increment the list after the position of parent by one . Got AC
:)