https://loj.ac/problem/6003
变化了下的最小路径覆盖,要注意边数巨多。。。
#include#include #include #include using namespace std;int biao[100];const int maxn = 10009;int head[maxn];int cur[maxn];int tot = 0;struct edge{ int v,nex,w;}e[maxn*20];void addedge(int u,int v,int w){ e[tot] = (edge){v,head[u],w}; head[u] = tot++; e[tot] = (edge){u,head[v],w}; head[v] = tot++;}int deep[maxn];int nowball;bool bfs(int S,int T){ for(int i=0;i<=2*nowball+1;i++){ deep[i] = 0; } queue q; deep[S] = 1; q.push(S); while(!q.empty()){ int now = q.front(); q.pop(); for(int i=head[now];i!=-1;i=e[i].nex){ int v = e[i].v; int w = e[i].w; if(deep[v]!=0 || w<=0) continue; deep[v] = deep[now]+1; if(v==T) return deep[T]; q.push(v); } } return deep[T];}int dfs(int now,int T,int maxflow){ if(now==T) return maxflow; int all =0; for(int &i=cur[now];i!=-1 &&all =nowball) continue; addedge(from*2,nowball*2+1,1); } addedge(0,nowball*2,1); addedge(nowball*2+1,1,1); kkk+=dinic(0,1); if(nowball-kkk<=n) continue; else{ break; } } nowball--; printf("%d\n",nowball); for(int i=1;i<=nowball;i++){ if(vis[2*i]==0) { print(2*i); printf("\n"); } } return 0;}