#ABC103D. Islands War
Islands War
题目描述
There are islands lining up from west to east, connected by bridges.
The -th bridge connects the -th island from the west and the -th island from the west.
One day, disputes took place between some islands, and there were requests from the inhabitants of the islands:
Request : A dispute took place between the -th island from the west and the -th island from the west. Please make traveling between these islands with bridges impossible.
You decided to remove some bridges to meet all these requests.
Find the minimum number of bridges that must be removed.
有 座岛屿自西向东排列,由 座桥梁连接。
(座)桥从西面连接着 (座)岛,从西面连接着 (座)岛。
有一天,一些岛屿之间发生了争端,岛上的居民提出了 个请求:
请求 :西边的 /那个岛和西边的 /那个岛之间发生了争端。请让这些岛屿之间的交通无法通过桥梁。
你决定拆除一些桥梁来满足所有这些 要求。
请找出必须拆除的桥梁的最小数量。
输入格式
输入内容按以下格式标准输入:
输出格式
打印必须拆除的桥梁的最小数量。
样例 #1
样例输入 #1
5 2
1 4
2 5
样例输出 #1
1
样例 #2
样例输入 #2
9 5
1 8
2 7
3 5
4 6
7 9
样例输出 #2
2
样例 #3
样例输入 #3
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
样例输出 #3
4
说明
数据规模与约定
- 所有输入值均为整数。
- 所有成对的 都是不同的。
样例 解释
从西面拆除连接第二岛和第三岛的桥梁,即可满足要求。