2026牛客国庆集训派对day7
Friends官方中文
题目描述
官方中文There are $n$ people standing in a line, numbered from $1$ to $n$ from left to right. Among these people, there are $m$ pairs of friends. Define an interval $[l,r]$ ($1 \leq l \leq r \leq n$) as friendly if and only if every pair of people within the interval are friends. How many friendly intervals are there?官方中文
输入格式
官方中文The first line contains two integers $n$ and $m$ ($1 \leq n, m \leq 10^6$), representing the number of people and the number of pairs of friends, respectively.
The next $m$ lines each contain two integers $u$ and $v$ ($1 \leq u < v \leq n$), representing a pair of friends.
It is guaranteed that there are no duplicate friend pairs in the input.官方中文
输出格式
官方中文Output a single integer representing the number of friendly intervals.官方中文
样例
Input #1
5 9
2 3
1 3
4 5
3 5
1 2
2 4
1 5
1 4
2 5Output #1
9题目信息
题面与样例版权归 牛客竞赛 及出题人所有;中文翻译由 AI 生成(官方原文),如有出入请以原文为准。