Can anybody please give me any hints for this Problem?
# | 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 | 151 |
Can anybody please give me any hints for this Problem?
Name |
---|
If you google "Knight distance", there will come a few pages with a general formula that's useful for this problem.
Let f(x, y) be the function that computes the distance in knight moves from point (0, 0) to point (x, y) with x ≥ y (if not, just swap them, the cartesian plane is symmetrical), and let d = x - y. Then the formula is...
(when y > d)
(when y ≤ d)
Once you know that, you can solve it with min-cost max-flow. Build a bipartite graph. Left nodes are knights and right nodes are points. Join each left node with each right node by setting capacity to 1 and cost equal to that knight distance to that point. Also join the source to every left node and all right nodes to the sink with capacity 1 and cost 0.