#P4214. Orange Juice Pipeline Upgrade

    ID: 17461 Type: Default 1000ms 256MiB

Orange Juice Pipeline Upgrade

Orange Juice Pipeline Upgrade

You have been hired to upgrade an old orange juice processing plant's transportation system. The system consists of pipelines and nodes. Every pipeline is bidirectional and each has a capacity of $1$ liter per second. Pipelines connect nodes, and each node (numbered from $1$ to $n$) is connected to at most $3$ pipelines. The node throughput is unlimited. For any two distinct nodes $s$ and $t$, the $s-t$ flow is defined as the maximum possible flow from $s$ (source) to $t$ (sink).

Your task is to calculate the sum of the flows for every pair of nodes $(a,b)$ with $a < b$. In other words, for every pair \(a, b\) where \(a < b\), compute the maximum flow from \(a\) to \(b\) (with each pipeline having capacity \(1\)) and output the sum of these flows.

inputFormat

The input consists of:

  • The first line contains two integers \(n\) and \(m\) representing the number of nodes and pipelines respectively.
  • Each of the next \(m\) lines contains two integers \(u\) and \(v\), indicating an undirected pipeline between nodes \(u\) and \(v\).

Note: Each pipeline is bidirectional, and each node is connected to at most 3 pipelines.

outputFormat

Output a single integer: the sum of the maximum flows for all pairs of nodes \((a, b)\) with \(a < b\).

sample

6 6
1 2
1 3
2 4
3 5
4 6
5 6
16