305761: CF1086F. Forest Fires

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Forest Fires

题意翻译

有一个无限大的网格图,在第0秒的时候,有$n$个格子会着火,每隔一秒,一个着火的格子会导致和它**八连通**的未着火的格子着火,定义一个着火格子的权值为它最早着火的时间,求$t$秒之后所有着火格子的权值和。 $n<=50$ $-10^8<=x_i,y_i<=10^8$ $0<=t<=10^8$

题目描述

Berland forest was planted several decades ago in a formation of an infinite grid with a single tree in every cell. Now the trees are grown up and they form a pretty dense structure. So dense, actually, that the fire became a real danger for the forest. This season had been abnormally hot in Berland and some trees got caught on fire! The second fire started is considered the second $ 0 $ . Every second fire lit up all intact neightbouring trees to every currently burning tree. The tree is neighbouring if it occupies adjacent by side or by corner cell. Luckily, after $ t $ seconds Berland fire department finally reached the location of fire and instantaneously extinguished it all. Now they want to calculate the destructive power of the fire. Let $ val_{x, y} $ be the second the tree in cell $ (x, y) $ got caught on fire. The destructive power is the sum of $ val_{x, y} $ over all $ (x, y) $ of burnt trees. Clearly, all the workers of fire department are firefighters, not programmers, thus they asked you to help them calculate the destructive power of the fire. The result can be rather big, so print it modulo $ 998244353 $ .

输入输出格式

输入格式


The first line contains two integers $ n $ and $ t $ ( $ 1 \le n \le 50 $ , $ 0 \le t \le 10^8 $ ) — the number of trees that initially got caught on fire and the time fire department extinguished the fire, respectively. Each of the next $ n $ lines contains two integers $ x $ and $ y $ ( $ -10^8 \le x, y \le 10^8 $ ) — the positions of trees that initially got caught on fire. Obviously, the position of cell $ (0, 0) $ on the grid and the directions of axes is irrelevant as the grid is infinite and the answer doesn't depend on them. It is guaranteed that all the given tree positions are pairwise distinct. The grid is infinite so the fire doesn't stop once it reaches $ -10^8 $ or $ 10^8 $ . It continues beyond these borders.

输出格式


Print a single integer — the sum of $ val_{x, y} $ over all $ (x, y) $ of burnt trees modulo $ 998244353 $ .

输入输出样例

输入样例 #1

1 2
10 11

输出样例 #1

40

输入样例 #2

4 1
2 2
1 3
0 2
2 4

输出样例 #2

18

输入样例 #3

3 0
0 0
-2 1
1 1

输出样例 #3

0

说明

Here are the first three examples. The grey cells have $ val = 0 $ , the orange cells have $ val = 1 $ and the red cells have $ val = 2 $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1086F/cb9e62b1e70abf36d285ed071b42fbdd39834039.png)

Input

题意翻译

有一个无限大的网格图,在第0秒的时候,有$n$个格子会着火,每隔一秒,一个着火的格子会导致和它**八连通**的未着火的格子着火,定义一个着火格子的权值为它最早着火的时间,求$t$秒之后所有着火格子的权值和。 $n<=50$ $-10^8<=x_i,y_i<=10^8$ $0<=t<=10^8$

加入题单

上一题 下一题 算法标签: