G - Chips

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

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, yi ≤ n) — 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.

Sample Input

Input
3 1
2 2
Output
0
Input
3 0
Output
1
Input
4 3
3 1
3 2
3 3
Output
1

Hint

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).

这道题其实是比较水的。

#include<iostream>
#include<stdio.h>
#define max1 10005
using namespace std;
int main()
{
int n,m;
int r[max1];
int c[max1];
scanf("%d%d",&n,&m);
int ans=;
for(int i=;i<n;i++)
r[max1]=,r[max1]=;
for(int i=;i<m;i++)
{
int a,b;
scanf("%d%d",&a,&b);
r[a]=;
c[b]=;
}
for(int i=;i<n;i++)
{
if(!r[i]) ans++;
if(!c[i]) ans++;
}
if(n%&&!r[n/+]&&!c[n/+])
ans--;
printf("%d\n",ans);
return ;
}

最新文章

  1. OpenCV成长之路(10):视频的处理
  2. C++函数传递指针面试题
  3. JavaScript创建命名空间、类及类成员
  4. webstorm 添加文件模板
  5. Codeforces Gym 100425A Luggage Distribution 二分 数学
  6. 自己封装的工具类,使用原生SwipeRefreshLayout+RecycleView实现下拉刷新和加载更多
  7. JAVA: httpclient 具体解释——第五章;
  8. phpstudy2018 安装xdebug扩展
  9. day17
  10. 自学工业控制网络之路1.5-典型的现场总线介绍DeviceNet
  11. 第五章703N 刷openwrt 挂载u盘
  12. Redux基础使用
  13. jQuery 常用效果
  14. windows 7 下elasticsearch5.0 安装head 插件
  15. Apache Roller 5.0.3 XXE漏洞分析
  16. Linux第七周学习总结——可执行程序的装载
  17. C语言宏定义中的#和##的作用【转】
  18. python 函数赋值
  19. English trip -- Iris老师整理的一般时态
  20. Spring中的统一异常处理方式

热门文章

  1. 一张图解释Hadoop IPC
  2. java笔记--查看和修改线程的优先级
  3. 我的grub.cfg配置文件
  4. ZeroMQ(java)中组件间数据传输(Pipe的实现)
  5. tomcat安全配置(二)
  6. linux rsync +inotify 实现 实时同步
  7. Linux Apache和Nginx网络模型详解
  8. Kruskal vs Borůvka
  9. PHP编译支持mysqli
  10. RAID阵列的初始化与管理