250...
500...
1000
No idea during the competition. Instead, I thought of a trick. I wanted to take a cha. Later I found that no one in the room submitted it...
Only the number of pre-processed steps from one point to another, and the complexity of the DP space is too high. Today, I saw how others preprocessed it. I am still very tender...
DP [dx] [dy] [m] indicates the number of cases in which (dx, Dy) is moved by M-step coordinates.
Perform a memory search.
const int MAXN = 55;const int MOD = 1e9+7;int dp[MAXN][MAXN][MAXN];int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};class WolfPackDivTwo {public: int dfs(int dx, int dy, int m) { if(dp[dx][dy][m] != -1) return dp[dx][dy][m]; int res = 0; if(m == 0) { res = (dx == 0 && dy == 0); } else { for(int i = 0; i < 4; ++i) { int xx = abs(dx + dir[i][0]); int yy = abs(dy + dir[i][1]); if(xx + yy > m - 1) continue; res = (res + dfs(xx, yy, m - 1))%MOD; } } return dp[dx][dy][m] = res; } int calc(vector <int> x, vector <int> y, int m) { int n = x.size(), tx, ty, i, ans = 0; CL(dp, -1); for(tx = x[0] - m; tx <= x[0] + m; ++tx) { for(ty = y[0] - m; ty <= y[0] + m; ++ty) { int tmp = 1; for(i = 0; i < n; ++i) { int dx = abs(tx - x[i]); int dy = abs(ty - y[i]); if(dx + dy > m) {tmp = 0; continue;} tmp = (tmp*dfs(dx, dy, m))%MOD; } ans = (ans + tmp)%MOD; } } return ans; }};