版本比较
题解 P5289 【[十二省联考2019]皮配】
正文
增加 5 行删除 5 行
94 行未改动95969798999910010110210310410510610610710810911011111211311311411511611711811912012112212212312412512621 行未改动14814915015115215215315415515614 行未改动94 行未改动 read(C0), read(C1), read(D0), read(D1); for(int i=1;i<=n;++i) read(b[i]), read(s[i]), city_sum[b[i]] += s[i], hate[i] = -1, ALL += s[i]; int K, x; read(K); while(K--) read(x), read(hate[x]), city_hate[b[x]] = true;
memset(f, 0, sizeof f), pre_f[0] = f[0] = 1; for(int i=1;i<=c;++i) if(!city_hate[i] and city_sum[i]) for(int j = C0, ts = city_sum[i]; j >= ts; -- j) pls(f[j], f[j-ts]); for(int i=1;i<=C0;++i) pre_f[i] = qm(pre_f[i-1] + f[i]);
memset(g, 0, sizeof g), pre_g[0] = g[0] = 1; for(int i=1;i<=n;++i) if(-1 == hate[i]) for(int j = D0, ts = s[i]; j >= ts; -- j) pls(g[j], g[j-ts]); for(int i=1;i<=D0;++i) pre_g[i] = qm(pre_g[i-1] + g[i]);
int Cs = 0, Ss = 0; memset(F, 0, sizeof F), F[0][0] = 1; memset(G, 0, sizeof G); for(int ct = 1; ct <= c; ++ ct) if(city_hate[ct]) { Cs += city_sum[ct], Cs = min(Cs, C0); for(int i=0;i<=Cs;++i) for(int j=0;j<=Ss;++j) G[i][j] = F[i][j];
for(int a=1;a<=n;++a) if(b[a] == ct and ~hate[a]) { const int t = s[a]; Ss += t, Ss = min(Ss, D0);21 行未改动 for(int i=0;i<=Cs;++i) for(int j=0;j<=Ss;++j) pls(F[i][j], G[i][j]); }
int res = 0; for(int i=0;i<=Cs;++i) for(int j=0;j<=Ss;++j) { int l1 = max(0, ALL - C1 - i), r1 = C0 - i; if(l1 > r1) continue;14 行未改动