Result: After 250, challenge step-1. Last rate-9. For the first time, TC fell two times in a row, but I had to think about it for the first time. I had to read the problem for the first time, and then a SIR called me... After the game, I realized that 450 was wrong. I thought it was possible to reach every point .. But after that, DIV2 was quickly completed .... DIV2 A: Compare DIV2 B directly with the previous one: greedy, after sorting the remaining number. First, take the largest number, and then find the smallest possible number, just matching the previously selected number plus can exceed your own score. Select the smallest number. DIV2C: it is easy to write. The enumerated coordinate ranges are roughly [-50,100], followed by the 150*150 enumerated target coordinates. Traverse all vertices. The number of steps from each point to the target point is known, probably the Coordinate Difference. Then, determine whether it is reachable. The number of remaining steps, of course, is the structure of n left n right, m upper m. Then, count the number of steps in each direction and combine the number. It would be nice if div2 is used this time... [Cpp] class WolfPackDivTwo {public: LL c [55] [55]; void Init () {for (int I = 0; I <= 50; I ++) {c [I] [0] = c [I] [I] = 1; for (int j = 1; j <I; j ++) c [I] [j] = (c [I-1] [j] + c [I-1] [J-1]) % MOD;} LL check (vi x, vi y, int cx, int cy, int m) {LL ans = 1; for (int I = 0; I <x. size (); I ++) {int a = abs (x [I]-cx) + abs (y [I]-cy ); if (a> m | (m-a) & 1) return 0; int up = 0, down = 0, left = 0, right = 0; int k = m-a; if (x [I]> cx) left = x [I]-cx; else right = cx-x [I]; I F (y [I]> cy) up = y [I]-cy; else up = cy-y [I]; LL t = 0; for (int j = 0; j * 2 <= k; j ++) {int l = left + j; int r = right + j; int u = up + (K-2 * j)/2; int d = down + (K-2 * j)/2; t = (c [m] [l] * c [m-l] [r]) % MOD) * c [m-l-r] [u] % MOD) + t) % MOD;} ans = (LL) ans * t) % MOD;} return ans ;} int calc (vector <int> x, vector <int> y, int m) {LL ans = 0; Init (); for (int I =-51; I <= 151; I ++) {for (int j =-51; j <= 151; j ++) {ans = (ans + check (x, y, i, j, m) % MOD ;}} retu Rn ans ;}} class WolfPackDivTwo {public: LL c [55] [55]; void Init () {for (int I = 0; I <= 50; I ++) {c [I] [0] = c [I] [I] = 1; for (int j = 1; j <I; j ++) c [I] [j] = (c [I-1] [j] + c [I-1] [J-1]) % MOD;} LL check (vi x, vi y, int cx, int cy, int m) {LL ans = 1; for (int I = 0; I <x. size (); I ++) {int a = abs (x [I]-cx) + abs (y [I]-cy ); if (a> m | (m-a) & 1) return 0; int up = 0, down = 0, left = 0, right = 0; int k = m-a; if (x [I]> cx) left = x [I]-cx; else right = cx-x [I]; if (y [I]> cy) up = y [I]-cy; else up = cy-y [I]; LL t = 0; for (int j = 0; j * 2 <= k; j ++) {int l = left + j; int r = right + j; int u = up + (K-2 * j)/2; int d = down + (K-2 * j)/2; t = (c [m] [l] * c [m-l] [r]) % MOD) * c [m-l-r] [u] % MOD) + t) % MOD;} ans = (LL) ans * t) % MOD;} return ans ;} int calc (vector <int> x, vector <int> y, int m) {LL ans = 0; Init (); for (int I =-51; I <= 151; I ++) {for (int j =-51; j <= 151; j ++) {ans = (ans + check (x, y, i, j, m) % MOD ;}} Return ans;} DIV1 A: it is about the same as DIV2 B. It is also greedy. After sorting, find the largest one. Then find another one that is as small as possible, and the sum of the selected one exceeds your score. The last one is to find the combination before the two. If there is no such combination, it cannot be found. DIV1 B: The question is incorrect .... I thought it was from 0, can reach the remaining N-1 points, can only haha. Is to say how everyone is to use from 0 to the N-1 to do the shortest circuit... Discretization the height. dp [I] [j] indicates the optimal solution when the height is w [j. Put it in spfa and update it continuously. TAT [cpp] class SkiResorts {public: long minCost (vector <string> r, vector <int> h) {int n = h. size (); int w [n]; LL dp [n] [n]; for (int I = 0; I <n; I ++) w [I] = h [I]; sort (w, w + n); bool in [n]; mem (in, false); mem (dp,-1 ); for (int I = 0; I <n; I ++) dp [0] [I] = abs (h [0]-w [I]); queue <int> que; que. push (0); in [0] = true; while (! Que. empty () {int u = que. front (); que. pop (); in [u] = false; for (int I = 0; I <n; I ++) {if (r [u] [I] = 'n') continue; for (int j = 0; j <N; j ++) {for (int k = 0; k <= j; k ++) {if (dp [I] [k] =-1 | dp [I] [k]> dp [u] [j] + abs (h [I]-w [k]) {dp [I] [k] = dp [u] [j] + abs (h [I]-w [k]); if (in [I] = false) {in [I] = true; que. push (I) ;}}}}} LL ans =-1; for (int I = 0; I <n; I ++) if (dp [n-1] [I]! =-1) {if (ans =-1 | dp [n-1] [I] <ans) ans = dp [n-1] [I];} return ans ;}} class SkiResorts {public: long minCost (vector <string> r, vector <int> h) {int n = h. size (); int w [n]; LL dp [n] [n]; for (int I = 0; I <n; I ++) w [I] = h [I]; sort (w, w + n); bool in [n]; mem (in, false); mem (dp,-1 ); for (int I = 0; I <n; I ++) dp [0] [I] = abs (h [0]-w [I]); queue <int> que; que. push (0); in [0] = true; while (! Que. empty () {int u = que. front (); que. pop (); in [u] = false; for (int I = 0; I <n; I ++) {if (r [u] [I] = 'n') continue; for (int j = 0; j <N; j ++) {for (int k = 0; k <= j; k ++) {if (dp [I] [k] =-1 | dp [I] [k]> dp [u] [j] + abs (h [I]-w [k]) {dp [I] [k] = dp [u] [j] + abs (h [I]-w [k]); if (in [I] = false) {in [I] = true; que. push (I) ;}}}}} LL ans =-1; for (int I = 0; I <n; I ++) if (dp [n-1] [I]! =-1) {www.2cto.com if (ans =-1 | dp [n-1] [I] <ans) ans = dp [n-1] [I];} return ans ;}}