正文
增加 39 行删除 39 行
127 行未改动全部展开1281291301311321331341351361371381396 行未改动1461471481491501511521531541551561571581591601613 行未改动16516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322415 行未改动2402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353366 行未改动127 行未改动全部展开::::info[code]```cpppre_def: [def function int read()begindef int x = 0, f = 1;def char ch = getchar();while !isdigit(ch) dobeginif ch == '-' do f = -1;ch = getchar();6 行未改动end_with_(x*f);enddef const int N = 110;def int m, n, k, ans, tmp[N], f[N][N], g[N], J[N][N];def bool vis[N], flag[N][N];def [new type (node)beginint x, y;end ] a[N], b[N];def function int pow2(int x)beginend_with_(x*x);3 行未改动beginrepeat (i) from 1 to n doif flag[i][x] and vis[i] dobeginvis[i] = 0;if tmp[i] == -1 or found(tmp[i]) dobegintmp[i] = x;end_with_(true);endendend_with_(false);enddef function void dfs(int x, int y )beginif y + g[x] >= ans do end_func;if x > m dobeginans = y;end_func;enddef int tmp2[N];repeat (i) from x to m dobeginrepeat (j) from 1 to n dobegintmp2[j] = tmp[j];if J[j][x] and f[j][x] >= i doflag[j][y+1] = 1;endfill (vis) with true;if found(y+1) do dfs(i+1, y+1);repeat (j) from 1 to n dobegintmp[j] = tmp2[j];if J[j][x] == 1 and f[j][x] >= i doflag[j][y+1] = 0;endendend]startm = read(); n = read(); k = read();repeat (i) from 1 to m do b[i].x = read(), b[i].y = read();repeat (i) from 1 to n do a[i].x = read(), a[i].y = read();repeat (i) from 1 to m dorepeat (j) from 1 to n doif pow2(a[j].x-b[i].x)+pow2(a[j].y-b[i].y) <= pow2(k) do J[j][i] = 1;repeat (i) from 1 to n dorepeat (j) from m to 1 (j dec) doif J[i][j] do f[i][j] = max(j, f[i][j+1]);fill (g) with INF;g[m+1] = 0;repeat (i) from m to 1 (i dec) dorepeat (j) from 1 to n doif J[j][i] do g[i] = min(g[i], g[f[j][i]+1] + 1);ans = n;15 行未改动```cpp#include <bits/stdc++.h>using namespace std;int read(){int x = 0, f = 1;char ch = getchar();while (!isdigit(ch)){if (ch == '-') f = -1;ch = getchar();}while (isdigit(ch)){x = (x<<3) + (x<<1) + ch - '0';ch = getchar();}return x*f;}const int N = 110;int m, n, k, ans, tmp[N], f[N][N], g[N], J[N][N];bool vis[N], flag[N][N];struct node { int x, y; } a[N], b[N];int pow2(int x) { return x * x; }bool found (int x){for (int i = 1; i <= n; i++)if (flag[i][x] && vis[i]){vis[i] = 0;if (tmp[i] == -1 || found(tmp[i])){tmp[i] = x;return 1;}}return 0;}void dfs(int x, int y ){if (y + g[x] >= ans) return;if (x > m){ans = y;return;}int tmp2[N];for (int i = x; i <= m; i++){for (int j = 1; j <= n; j++){tmp2[j] = tmp[j];if (J[j][x] && f[j][x] >= i)flag[j][y+1] = 1;}memset(vis, true, sizeof(vis));if (found(y+1)) dfs(i+1, y+1);for (int j = 1; j <= n; j++){tmp[j] = tmp2[j];if (J[j][x] == 1 && f[j][x] >= i)flag[j][y+1] = 0;}}}int main(){m = read(); n = read(); k = read();for (int i = 1; i <= m; i++) b[i].x = read(), b[i].y = read();for (int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read();for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++)if (pow2(a[j].x-b[i].x)+pow2(a[j].y-b[i].y) <= pow2(k)) J[j][i] = 1;for (int i = 1; i <= n; i++)for (int j = m; j >= 1; j--)if (J[i][j]) f[i][j] = max(j, f[i][j+1]);memset(g, 0x3f, sizeof(g));g[m+1] = 0;for (int i = m; i >= 1; i--)for (int j = 1; j <= n; j++)if (J[j][i]) g[i] = min(g[i], g[f[j][i]+1] + 1);ans = n;memset(tmp, -1, sizeof(tmp));dfs(1, 0);printf("%d\n", ans);return 0;}```::::然后运行一遍,就能发现输出了 $2$。6 行未改动127 行未改动全部展开1281291301311321331341351361371381396 行未改动1461471481491501511521531541551561571581591601613 行未改动16516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322415 行未改动2402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353366 行未改动127 行未改动全部展开::::info[code]```cpppre_def: [def function int read()begindef int x = 0, f = 1;def char ch = getchar();while !isdigit(ch) dobeginif ch == '-' do f = -1;ch = getchar();6 行未改动end_with_(x*f);enddef const int N = 110;def int m, n, k, ans, tmp[N], f[N][N], g[N], J[N][N];def bool vis[N], flag[N][N];def [new type (node)beginint x, y;end ] a[N], b[N];def function int pow2(int x)beginend_with_(x*x);3 行未改动beginrepeat (i) from 1 to n doif flag[i][x] and vis[i] dobeginvis[i] = 0;if tmp[i] == -1 or found(tmp[i]) dobegintmp[i] = x;end_with_(true);endendend_with_(false);enddef function void dfs(int x, int y )beginif y + g[x] >= ans do end_func;if x > m dobeginans = y;end_func;enddef int tmp2[N];repeat (i) from x to m dobeginrepeat (j) from 1 to n dobegintmp2[j] = tmp[j];if J[j][x] and f[j][x] >= i doflag[j][y+1] = 1;endfill (vis) with true;if found(y+1) do dfs(i+1, y+1);repeat (j) from 1 to n dobegintmp[j] = tmp2[j];if J[j][x] == 1 and f[j][x] >= i doflag[j][y+1] = 0;endendend]startm = read(); n = read(); k = read();repeat (i) from 1 to m do b[i].x = read(), b[i].y = read();repeat (i) from 1 to n do a[i].x = read(), a[i].y = read();repeat (i) from 1 to m dorepeat (j) from 1 to n doif pow2(a[j].x-b[i].x)+pow2(a[j].y-b[i].y) <= pow2(k) do J[j][i] = 1;repeat (i) from 1 to n dorepeat (j) from m to 1 (j dec) doif J[i][j] do f[i][j] = max(j, f[i][j+1]);fill (g) with INF;g[m+1] = 0;repeat (i) from m to 1 (i dec) dorepeat (j) from 1 to n doif J[j][i] do g[i] = min(g[i], g[f[j][i]+1] + 1);ans = n;15 行未改动```cpp#include <bits/stdc++.h>using namespace std;int read(){int x = 0, f = 1;char ch = getchar();while (!isdigit(ch)){if (ch == '-') f = -1;ch = getchar();}while (isdigit(ch)){x = (x<<3) + (x<<1) + ch - '0';ch = getchar();}return x*f;}const int N = 110;int m, n, k, ans, tmp[N], f[N][N], g[N], J[N][N];bool vis[N], flag[N][N];struct node { int x, y; } a[N], b[N];int pow2(int x) { return x * x; }bool found (int x){for (int i = 1; i <= n; i++)if (flag[i][x] && vis[i]){vis[i] = 0;if (tmp[i] == -1 || found(tmp[i])){tmp[i] = x;return 1;}}return 0;}void dfs(int x, int y ){if (y + g[x] >= ans) return;if (x > m){ans = y;return;}int tmp2[N];for (int i = x; i <= m; i++){for (int j = 1; j <= n; j++){tmp2[j] = tmp[j];if (J[j][x] && f[j][x] >= i)flag[j][y+1] = 1;}memset(vis, true, sizeof(vis));if (found(y+1)) dfs(i+1, y+1);for (int j = 1; j <= n; j++){tmp[j] = tmp2[j];if (J[j][x] == 1 && f[j][x] >= i)flag[j][y+1] = 0;}}}int main(){m = read(); n = read(); k = read();for (int i = 1; i <= m; i++) b[i].x = read(), b[i].y = read();for (int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read();for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++)if (pow2(a[j].x-b[i].x)+pow2(a[j].y-b[i].y) <= pow2(k)) J[j][i] = 1;for (int i = 1; i <= n; i++)for (int j = m; j >= 1; j--)if (J[i][j]) f[i][j] = max(j, f[i][j+1]);memset(g, 0x3f, sizeof(g));g[m+1] = 0;for (int i = m; i >= 1; i--)for (int j = 1; j <= n; j++)if (J[j][i]) g[i] = min(g[i], g[f[j][i]+1] + 1);ans = n;memset(tmp, -1, sizeof(tmp));dfs(1, 0);printf("%d\n", ans);return 0;}```::::然后运行一遍,就能发现输出了 $2$。6 行未改动