题意:给出一张网络流构成的图,给出每对点之间的流量,要求输出流的方向。
思路:平衡出入流,入流=出流=流量>>1 以源点为突破口类似拓扑的方式写就好了。
//平衡出入流
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<stack>
using namespace std;
const int maxn=300000;
const int maxm=600000;
int n;
struct node
{
int u,v,w,next,id;
}edge[maxm];
int in[maxn],out[maxn];
int em;
int head[maxn];
void addedge(int u,int v,int w,int _id)
{
edge[em].id=_id;
edge[em].u=u;
edge[em].v=v;
edge[em].w=w;
edge[em].next=head[u];
head[u]=em++;
}
stack<int>q;
int dir[maxm];
int e1[maxn],e2[maxn];
void topo()
{
while(!q.empty()) q.pop();
q.push(1);
in[1]=out[1]=0;
while(!q.empty())
{
int u=q.top();
q.pop();
for(int i=head[u];~i;i=edge