Unfortunately Codeforces fails to show formulas in an editorial and I can't even press on "Preview" button :( While it doesn't work as intended, I put a bit ugly pdf-version of an editorial here. Unfortunately without model solution sources yet.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Unfortunately Codeforces fails to show formulas in an editorial and I can't even press on "Preview" button :( While it doesn't work as intended, I put a bit ugly pdf-version of an editorial here. Unfortunately without model solution sources yet.
Name |
---|
" ... Pascal triangle and started to investigate properties of binomial coefficients located on the same line. That was the wrong way :)"
This is also a good way, the "Pascal triangle" tells me that we are finding coefficients of xc in (xa + xb)0 + (xa + xb)1 + (xa + xb)2 + ..., then it is easy to see S(C) = S(C-A) + S(C-B).
Want to share my solution to E. It's seems to be isomorphic to what is written in the editorial but If I was to implement what is in editorial I would get much harder solution.
Let's root the tree in any vertex, now suppose pair of vertices u,v (au < av). If v is not in the subtree of u then it adds 1 to answer of all vertices in subtree of u. If it in the subtree of to — some direct child of u then it adds 1 to answer of all vertices except vertices in subtree of to which means add 1 everywhere and add -1 to subtree of to
Now process vertices u in decreasing order of its value in groups of vertices of same value: you need to know how many vertices v in each subtree (it's a range query) and outside of subtree of u (it's all others), and add answers to some subtrees. Adding to subtrees is either adding to a range in tin order or may be done offline.