2018牛客网暑期ACM多校训练营(第二场)I- car ( 思维)

时间:2023-03-08 20:19:04
2018牛客网暑期ACM多校训练营(第二场)I- car  ( 思维)

2018牛客网暑期ACM多校训练营(第二场)I- car

链接:https://ac.nowcoder.com/acm/contest/140/I来源:牛客网

时间限制:C/C++ 1秒,其他语言2秒

空间限制:C/C++ 131072K,其他语言262144K

64bit IO Format: %lld

题目描述

White Cloud has a square of n*n from (1,1) to (n,n).

White Rabbit wants to know the maximum number of cars that can be put into to ensure that there is a way that allows all cars to perform their entire journey without damage.

(update: all cars should start at the edge of the square and go towards another side, cars which start at the corner can choose either of the two directions)

For example, in a 5*5 square

2018牛客网暑期ACM多校训练营(第二场)I- car  ( 思维)

legal

2018牛客网暑期ACM多校训练营(第二场)I- car  ( 思维)

illegal(These two cars will collide at (4,4))

2018牛客网暑期ACM多校训练营(第二场)I- car  ( 思维)

illegal (One car will go into a damaged grid)

输入描述:

The first line of input contains two integers n and m(n <= 100000,m <= 100000)For the next m lines,each line contains two integers x,y(1 <= x,y <= n), denoting the grid which is damaged by White Cloud.

输出描述:

Print a number,denoting the maximum number of cars White Rabbit can put into.

示例1

输入

[复制](javascript:void(0)