正文
增加 16 行删除 16 行
72 行未改动73747576777879808149 行未改动13113213313413513613713813937 行未改动177178179180181182183184185171 行未改动全部展开357358359360361362363364365145 行未改动全部展开51151251351451551651751851940 行未改动56056156256356456556656756834 行未改动60360460560660760860961061157 行未改动66967067167267367467567667780 行未改动75875976076176276376476576679 行未改动84684784884985085185285385498 行未改动95395495595695795895996096189 行未改动105110521053105410551056105710581059142 行未改动全部展开12021203120412051206120712081209121079 行未改动1290129112921293129412951296129712981,040 行未改动全部展开233923402341234223432344234523462347247 行未改动全部展开259525962597259825992600260126022603293 行未改动全部展开72 行未改动#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define PID pair<int, double>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);using db=double;using ll=long long;49 行未改动}```## T2求$$ \sum_{k=0}^m \binom{n-k}{m-k} \binom{r+k}{k}$$对 $998244353$ 取模。37 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);171 行未改动全部展开#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);145 行未改动全部展开#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);40 行未改动k2-=dp[i-1][(l2+j-1)%m];k2+=dp[i-1][(r2+j)%m];dp[i][j]=max(k1*1.0/(r1-l1+1),k2*1.0/(r2-l2+1));}}printf("%.2lf",dp[n][0]);return 0;}34 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);57 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);80 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);79 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);98 行未改动[原题](https://www.luogu.com.cn/problem/P9691)考虑设状态 $f_i$ 为前 $i$ 个的最小代价,钦定 $i$ 必选,于是给序列末尾加个 $0$。考虑转移,非常朴素:$$f_i= \min_j f_j+a_i$$考虑 $j$ 的限制条件,首先对于合法的转移,$(j,i)$ 间不能有一个完整的区间,否则这个区间就没法被考虑到,于是设 $pre_i$ 为能转移到 $i$ 的最小的 $j$,把 $pre_i$ 预处理出来,然后上面转移是个经典的单调队列,~~当然想用线段树多个 log 也行~~。89 行未改动// freopen("114514.out","w",stdout);n=read();for(rg int i=1;i<=n;i++){a[i]=read();for(rg int j=1;j<=i;j++)p[i][j]=(p[i-1][j]+qpow(a[i]%j,j,j))%j;}g[0][0]=1;for(rg int j=1;j<=n;j++){142 行未改动全部展开for(rg int j=1;j<=n;j++)for(rg int k=1;k<=m;k++)p[abs(j-x)+abs(k-y)]++;bool flag=1;for(rg int i=0;i<=b;i++)if(cnt[i]!=p[i]){flag=0;break;}79 行未改动可以将与 $i$ 这个点连的边合并成一条路径,两个单独的路径合并可以使操作次数减 $1$。分别考虑奇数条边与偶数条边的转移即可。```cpp#define mp make_pairconst int N=1e5+10;int n;PII f[N][2];vector<PII> e[N];1,040 行未改动全部展开}scanf("%s",s+1);rebuild();dfs(root,0);if(tot==0) return write(0),0;// write(tot),pc(' '),write(num),pc(' '),write(len),puts("");write((tot-1)*2+num-len);return 0;}247 行未改动全部展开}for(rg int i=1;i<=n;i++){for(auto p:v[i]) add(1,p.fi,p.se,-1);PII res=query(1,L[i],R[i]);if(res.fi){for(rg int i=1;i<=n;i++) write(-1),pc(' ');return 0;}ans[res.se]=i;293 行未改动全部展开72 行未改动73747576777879808149 行未改动13113213313413513613713813937 行未改动177178179180181182183184185171 行未改动全部展开357358359360361362363364365145 行未改动全部展开51151251351451551651751851940 行未改动56056156256356456556656756834 行未改动60360460560660760860961061157 行未改动66967067167267367467567667780 行未改动75875976076176276376476576679 行未改动84684784884985085185285385498 行未改动95395495595695795895996096189 行未改动105110521053105410551056105710581059142 行未改动全部展开12021203120412051206120712081209121079 行未改动1290129112921293129412951296129712981,040 行未改动全部展开233923402341234223432344234523462347247 行未改动全部展开259525962597259825992600260126022603293 行未改动全部展开72 行未改动#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define PID pair<int, double>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);using db=double;using ll=long long;49 行未改动}```## T2求$$ \sum_{k=0}^m \binom{n-k}{m-k} \binom{r+k}{k}$$对 $998244353$ 取模。37 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);171 行未改动全部展开#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);145 行未改动全部展开#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);40 行未改动k2-=dp[i-1][(l2+j-1)%m];k2+=dp[i-1][(r2+j)%m];dp[i][j]=max(k1*1.0/(r1-l1+1),k2*1.0/(r2-l2+1));}}printf("%.2lf",dp[n][0]);return 0;}34 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);57 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);80 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);79 行未改动#define pc putchar#define rg register#define LB lower_bound#define UB upper_bound#define PII pair<int, int>#define PDI pair<double, int>#define fi first#define se second#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);98 行未改动[原题](https://www.luogu.com.cn/problem/P9691)考虑设状态 $f_i$ 为前 $i$ 个的最小代价,钦定 $i$ 必选,于是给序列末尾加个 $0$。考虑转移,非常朴素:$$f_i= \min_j f_j+a_i$$考虑 $j$ 的限制条件,首先对于合法的转移,$(j,i)$ 间不能有一个完整的区间,否则这个区间就没法被考虑到,于是设 $pre_i$ 为能转移到 $i$ 的最小的 $j$,把 $pre_i$ 预处理出来,然后上面转移是个经典的单调队列,~~当然想用线段树多个 log 也行~~。89 行未改动// freopen("114514.out","w",stdout);n=read();for(rg int i=1;i<=n;i++){a[i]=read();for(rg int j=1;j<=i;j++)p[i][j]=(p[i-1][j]+qpow(a[i]%j,j,j))%j;}g[0][0]=1;for(rg int j=1;j<=n;j++){142 行未改动全部展开for(rg int j=1;j<=n;j++)for(rg int k=1;k<=m;k++)p[abs(j-x)+abs(k-y)]++;bool flag=1;for(rg int i=0;i<=b;i++)if(cnt[i]!=p[i]){flag=0;break;}79 行未改动可以将与 $i$ 这个点连的边合并成一条路径,两个单独的路径合并可以使操作次数减 $1$。分别考虑奇数条边与偶数条边的转移即可。```cpp#define mp make_pairconst int N=1e5+10;int n;PII f[N][2];vector<PII> e[N];1,040 行未改动全部展开}scanf("%s",s+1);rebuild();dfs(root,0);if(tot==0) return write(0),0;// write(tot),pc(' '),write(num),pc(' '),write(len),puts("");write((tot-1)*2+num-len);return 0;}247 行未改动全部展开}for(rg int i=1;i<=n;i++){for(auto p:v[i]) add(1,p.fi,p.se,-1);PII res=query(1,L[i],R[i]);if(res.fi){for(rg int i=1;i<=n;i++) write(-1),pc(' ');return 0;}ans[res.se]=i;293 行未改动全部展开