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

  • 2018-07-21
  • 20
  • 0

题目:

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

legal

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

illegal (One car will go into a damaged grid)

Input:

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.

Output:

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

Sample Input:

2 0

Sample Output:

4

Hint:

题目链接

根据样例提示可知若没有damage的点则可以放2n-(n \% 2)(若n为奇数则中间行和中间列只能放一辆车)辆车,最后再判断damage点减一下就是答案。

AC代码:

评论

还没有任何评论,你来说两句吧