CF675B Restoring Painting
题目描述
有一个九宫格,每个格子的值都在 $[1,n]$ 的区间内,现给出它上下左右四格的值,要求每一个 $2\times2$ 的方格的总和都相等,请你求出共有多少种填法。如果 $2\times2$ 格子的总和等于 $0$ ,则表示有数据被记错了。如果在不同的 $2\times2$ 的方格中包含两个不同的整数,则认为两个 $2\times2$ 的方格是不同的。
输入格式
一行,包含五个整数 $n$ , $a$ , $b$ , $c$ 和 $d$ ( $1\le n\le 10^5$ , $1\le a,b,c,d\le n$ ) 。
输出格式
仅输出一个整数,表示填法的总数。
#### 样例解释:
样例1的两种方法如下: 
样例2的六种方法如下:

说明/提示
Below are all the possible paintings for the first sample. 
In the second sample, only paintings displayed below satisfy all the rules. 