ACM2314为什么会出现Runtime Error 请告诉帮我看看
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<functional>
#include<algorithm>
#include<queue>
#define MAXN 210
#define MAXM 100000
#define INF1 1000000
#define INF2 100000
using namespace std;
typedef struct Edge
{
int cap;
int next,u,v;
}edge;
edge e[MAXM];
int N,M;
int s,t,edges;
int head[MAXN],level[MAXN];
int id[MAXN],mlow[MAXN];
void init()
{
memset(id,0,sizeof(id));
edges=0;
memset(head,0,sizeof(head));
}
void addedge(int u,int v,int cap)
{
e[edges].cap=cap;
e[edges].v=v;
e[edges].next=head[u];
head[u]=edges;
edges++;
e[edges].cap=0;
e[edges].v=u;
e[edges].next=head[v];
head[v]=edges;
edges++;}
bool bfs()
{
for(int i=0;i<=t;i++)level[i]=-1;
queue<int>q;
q.push(s);
level[s]=0;
int u;
while(!q.empty())
{
u=q.front();
q.pop();
for(int i=head[u];i!=0;i=e[i].next)
{
int v=e[i].v;
if(level[v]==-1&&e[i].cap>0)
{
level[v]=level[u]+1;
q.push(v);
}
}
}
if(level[t]==-1)return 0;
return 1;
}
int dfs(int x,int cap)
{
if(x==t)return cap;
int temp=cap;
for(int i=head[x];i!=0;i=e[i].next)
{
int v=e[i].v;
if(level[v]==level[x]+1&&temp>0&&e[i].cap>0)
{
int tt=dfs(v,min(temp,e[i].cap));
e[i].cap-=tt;
e[i^1].cap+=tt;
temp-=tt;
}
}
return cap-temp;
}
void dinic()
{
while(bfs())
{
while(dfs(s,INF1));
}
}
int main()
{
int T,i,u,v,c;;
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&N,&M);
s=0;t=N+1;
init();
for(i=0;i<M;i++)
{
scanf("%d %d %d %d",&u,&v,&mlow[i],&c);
id[u]-=mlow[i];
id[v]+=mlow[i];
addedge(u,v,c-mlow[i]);
}
for(i=1;i<=N;i++)
{
if(id[i]>0)addedge(s,i,id[i]);
else if(id[i]<0)addedge(i,t,-id[i]);
}
dinic();
int flag=0;
for(i=head[s];i!=0;i=e[i].next)
{
if(e[i].cap)flag=1;
}
if(flag==0)
{
printf("YES\n");
for(i=0;i<M;i++)
{
printf("%d\n",e[(i<<1)^1].cap+mlow[i]);
}
}
else printf("NO\n");
printf("\n");
}
return 0;
}