版本比较
DLMY Solution: April Fool's Contest - Extra Part
正文
增加 39 行删除 39 行
127 行未改动全部展开1281291301311321321331341351351361371381396 行未改动1461471481491501501511521531541551561571571581591601613 行未改动16516616716816916917017117217317217317417517617617717817918018118218318418518518618718718818919019119219319419419519619719819920020020120220220320420520620720820921021021121221321421521621721821922022022122222322415 行未改动2402412422432442442452462472472482492502512522532542552562572582572582592602612622622632642652652662672682692702712722732742752742752762772782772782792802812812822832842852862872882892902902912922922932942952962972982992993003013013023033043053053063073073083093103113123113123133143143153163173183193203213223233243233243253263273283293293303313323323333343353366 行未改动127 行未改动全部展开::::info[code]```cpppre_def: [
def function int read() def function int read()begin def int x = 0, f = 1; def char ch = getchar(); def char ch = getchar(); while !isdigit(ch) do begin if ch == '-' do f = -1; ch = getchar();6 行未改动 end_with_(x*f);end
def const int N = 110;def int m, n, k, ans, tmp[N], f[N][N], g[N], J[N][N]; 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)begin int x, y;end ] a[N], b[N]; end ] a[N], b[N];
def function int pow2(int x)begin end_with_(x*x);3 行未改动begin repeat (i) from 1 to n do if flag[i][x] and vis[i] do begin vis[i] = 0; vis[i] = 0; if tmp[i] == -1 or found(tmp[i]) do begin tmp[i] = x; end_with_(true); tmp[i] = x; end_with_(true); end end end_with_(false); end_with_(false);end
def function void dfs(int x, int y )begin if y + g[x] >= ans do end_func; if x > m do begin ans = y; end_func; end_func; end def int tmp2[N]; def int tmp2[N]; repeat (i) from x to m do begin repeat (j) from 1 to n do begin tmp2[j] = tmp[j]; if J[j][x] and f[j][x] >= i do flag[j][y+1] = 1; flag[j][y+1] = 1; end fill (vis) with true; if found(y+1) do dfs(i+1, y+1); repeat (j) from 1 to n do begin tmp[j] = tmp2[j]; tmp[j] = tmp2[j]; if J[j][x] == 1 and f[j][x] >= i do flag[j][y+1] = 0; flag[j][y+1] = 0; end endend
]
start m = read(); n = read(); k = read(); m = 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 do repeat (j) from 1 to n do if 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 do repeat (j) from m to 1 (j dec) do if J[i][j] do f[i][j] = max(j, f[i][j+1]); fill (g) with INF; g[m+1] = 0; g[m+1] = 0; repeat (i) from m to 1 (i dec) do repeat (j) from 1 to n do if 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 read(){ int x = 0, f = 1; char ch = getchar(); 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; } return x*f;}
const int N = 110;int m, n, k, ans, tmp[N], f[N][N], g[N], J[N][N]; 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]; 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])) vis[i] = 0; if (tmp[i] == -1 || found(tmp[i])) { tmp[i] = x; return 1; tmp[i] = x; return 1; } } return 0; return 0;}
void dfs(int x, int y ){ if (y + g[x] >= ans) return; if (x > m) { ans = y; return; return; } int tmp2[N]; 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; flag[j][y+1] = 1; } memset(vis, true, sizeof(vis)); 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]; tmp[j] = tmp2[j]; if (J[j][x] == 1 && f[j][x] >= i) flag[j][y+1] = 0; flag[j][y+1] = 0; } }} int main()
int main(){ m = read(); n = read(); k = read(); 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; 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)); memset(tmp, -1, sizeof(tmp)); dfs(1, 0); printf("%d\n", ans); return 0; return 0;}```::::然后运行一遍,就能发现输出了 $2$。6 行未改动