5998: 芯片

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

B. 芯片
每次测试的时间限制
1 秒
每个测试的内存限制
256 兆字节
输入
标准输入
输出
标准输出
杰拉尔德玩下面的游戏。他有一个大小为n×n个细胞的方格场,其中m个不同的细胞被禁止。在比赛之前,他必须在一些边框(但不是角落)板上放置一些筹码。然后,在n-1分钟内,杰拉尔德每分钟将每个芯片移动到相邻的单元中。他将每个芯片从其原始边缘移动到相反的边缘。杰拉尔德在这场比赛中输了三种情况:
  • 至少有一个芯片至少一次落入被禁止的细胞。
  • 至少有一次两个芯片在同一单元上。
  • 至少一次两个筹码在一分钟内交换(例如,如果您将两个筹码放在一行长度均匀的两个相对边框单元格上,则这种情况发生在行的中间)。
在这种情况下,他输了,赚了0分。当没有发生这样的事情时,他赢了并获得的积分等于他设法放在棋盘上的筹码数量。帮助杰拉尔德获得最多的积分。
输入
第一行包含两个空格分隔的整数 n 和 m (2≤n≤1000, 0≤m≤105) - 字段的大小和禁止单元格的数量。接下来的 m 行各包含两个空格分隔的整数。具体来说,这些行的第 i 条包含数字 x i 和 y i (1≤x i,y i≤n) − 第 i 个禁止单元格的坐标。所有给定的单元格都是不同的。
考虑从上到下从 1 到 n 编号的字段行,以及从左到右从 1 到 n 的列 −。

输出
打印一个整数 - 杰拉尔德在这个游戏中可以获得的最高积分。
例子
输入
3 1
2 2
输出
0
输入
3 0
输出
1
输入
4 3
3 1
3 2
3 3
输出
1
注意
在第一个测试中,答案等于零,因为我们不能将芯片放入角落单元格中。
在第二个样本中,我们可以将一个芯片放入电池 (1, 2)、电池 (3, 2)、电池 (2, 1) 或电池 (2, 3) 中。我们不能放置两个筹码。
在第三个样本中,我们只能将一个芯片放入电池(2,1)或电池(2,4)中。
B. Chips
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Gerald plays the following game. He has a checkered field of size n×n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n-1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original edge to the opposite edge. Gerald loses in this game in each of the three cases:
  • At least one of the chips at least once fell to the banned cell.
  • At least once two chips were on the same cell.
  • At least once two chips swapped in a minute (for example, if you stand two chips on two opposite border cells of a row with even length, this situation happens in the middle of the row).
In that case he loses and earns 0 points. When nothing like that happened, he wins and earns the number of points equal to the number of chips he managed to put on the board. Help Gerald earn the most points.
Input
The first line contains two space-separated integers n and m (2≤n≤1000, 0≤m≤105) − the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1≤xi,yin) − the coordinates of the i-th banned cell. All given cells are distinct.
Consider the field rows numbered from top to bottom from 1 to n, and the columns − from left to right from 1 to n.

Output
Print a single integer − the maximum points Gerald can earn in this game.
Examples
Input
3 1
2 2
Output
0
Input
3 0
Output
1
Input
4 3
3 1
3 2
3 3
Output
1
Note
In the first test the answer equals zero as we can't put chips into the corner cells.
In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.
In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).

输入样例 复制


输出样例 复制