m<=79, n<=100

# Solution

### 1.对于原图中一条流量限制在[l,r],连接(u,v)的边,按如下方式建边:

(S,v,l),(u,T,l),(u,v,r-l)

## code

#include<bits/stdc++.h>
using namespace std;
#define re register
#define ll long long
#define in inline
#define get getchar()
{
int t=0,x=1; char ch=get;
while(ch!='-' && (ch<'0' || ch>'9')) ch=get;
if(ch=='-') ch=get, x=-1;
while(ch<='9' && ch>='0') t=t*10+ch-'0', ch=get;
return t*x;
}
const int _=310;
const int inf=0x3f3f3f3f;
struct edge{
int to,ne,w,val;
}e[_*_<<3];
int h[_], tot=1, n, S, T,TT,m,SS;
int dis[_], cur[_], vis[_];
in int bfs()
{
memset(vis,0,sizeof(vis));
memset(dis,0x3f,sizeof(dis));
queue<int >q;
q.push(SS); dis[SS]=0;
while(!q.empty())
{
int u=q.front(); q.pop();
cur[u]=h[u];vis[u]=0;
for(re int i=h[u];i;i=e[i].ne)
{
int v=e[i].to;
if(dis[v]>dis[u]+e[i].val && e[i].w)
{
dis[v]=dis[u]+e[i].val;
if(!vis[v]){ vis[v]=1; q.push(v);}
}
}
}
return dis[TT]!=inf;
}
ll cost=0;
in int dfs(int u,int flow)
{
if(u==TT || !flow) return flow;
int used=0, d; vis[u]=1;
for(re int i=cur[u];i;i=e[i].ne)
{
int v=e[i].to; cur[u]=i;
if(!vis[v] && e[i].w && dis[v]==dis[u]+e[i].val)
{
d=dfs(v,min(flow-used,e[i].w));
if(!d) continue;
used+=d, e[i].w-=d, e[i^1].w+=d, cost+=1ll*d*e[i].val;
if(used==flow) break;
}
}
return used;
}
int maxflow;
in void dinic()
{
int qwe;
while(bfs())
while(memset(vis,0,sizeof(vis)), qwe=dfs(SS,inf)){ maxflow+=qwe;}
}
int v[_],d[_];
in void add_edge(int x,int y,int w,int val) // 在新图上的边
{
e[++tot].ne=h[x], e[tot].to=y, e[tot].w=w, e[tot].val=val, h[x]=tot;
e[++tot].ne=h[y], e[tot].to=x, e[tot].w=0, e[tot].val=-val, h[y]=tot;
}
in void add(int x,int y,int lf,int rf,int val) //加入有上下界的原图边
{
if(rf-lf>0) add_edge(x,y,rf==inf ? inf : rf-lf,val);
}
int main()
{
S=n*2+1, T=S+1, SS=T+1, TT=SS+1;
int kt=TT+1;
for(re int i=1;i<=n;++i) {
}
for(re int i=1;i<n;++i)
{
for(re int j=1;j+i<=n;++j)
{