hdu 3376 : Matrix Again【MCMF】

#include<bits/stdc++.h>
using namespace std;

const int N=720005;
const int M=7200050;
const int INF=0x3f3f3f3f;
struct Edge
{
int to,next;
int c,f,w;
Edge(){}
Edge(int to_,int c_,int f_,int w_,int next_)
{
to=to_,c=c_,f=f_,w=w_,next=next_;
}
}edge[M<<1];
bool inq[N];
int d[N],p[N],a[N];
void init()
{
tot=0;
}
void addedge(int u,int v,int c,int w)
{
}
bool spfa(int s,int t,int& flow,int& cost)
{
memset(d,INF,sizeof(d));
memset(inq,false,sizeof(inq));
queue<int> Q;
d[s]=0,inq[s]=true,a[s]=INF;
Q.push(s);
while(!Q.empty())
{
int u=Q.front();Q.pop();
inq[u]=false;
{
Edge& e=edge[i]; int v=e.to;
if(e.c>e.f&&d[v]>d[u]+e.w)
{
d[v]=d[u]+e.w,p[v]=i;
a[v]=min(a[u],e.c-e.f);
if(!inq[e.to]) Q.push(e.to),inq[e.to]=true;
}
}
}
if(d[t]==INF) return false;
flow+=a[t],cost+=d[t]*a[t];
for(int u=t;u!=s;u=edge[p[u]^1].to)
{
edge[p[u]].f+=a[t];
edge[p[u]^1].f-=a[t];
}
return true;
}
void Mincost(int s,int t,int& flow,int& cost)
{
flow=cost=0;
while(spfa(s,t,flow,cost));
}

//==============================================
int n;
inline int id(int x,int y)
{
return x*n+y;
}
int main()
{
while(~scanf("%d",&n))
{
init();
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
int temp;
scanf("%d",&temp);
}