Problem 3022 --Faraway

3022: Faraway

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
nn soldiers are dispatched to somewhere in Byteland. These soldiers are going to set off now, but the target location is not so clear. 

Assume the target location is at (xe,ye)(xe,ye), it is clear that xe,yexe,ye are both non-negative integers within [0,m][0,m]. For the ii-th soldier, the only thing he knows is that (|xi−xe|+|yi−ye|)modki=ti(|xi−xe|+|yi−ye|)modki=ti

To find the correct target location, these soldiers are working on the information they have now. Please write a program to figure out the number of possible target locations.
The first line of the input contains an integer T(1≤T≤10)T(1≤T≤10), denoting the number of test cases. 

In each test case, there are two integers n,m(1≤n≤10,1≤m≤109)n,m(1≤n≤10,1≤m≤109) in the first line, denoting the number of soldiers and the upper bound of xe,yexe,ye

For the next nn lines, each line contains four integers xi,yi,ki,ti(0≤xi,yi≤m,2≤ki≤5,0≤ti<ki)xi,yi,ki,ti(0≤xi,yi≤m,2≤ki≤5,0≤ti<ki), denoting what each soldier knows.
For each test case, print a single line containing an integer, denoting the number of possible target locations.
2
2 5
1 2 4 2
3 1 2 1
2 5
1 2 4 2
1 2 4 3
10
0

推荐代码 查看3022 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$215 $ms] 淡意的温柔 591123 2020-06-06 08:16:28
内存最少[$0 $KB] 淡意的温柔 591123 2020-06-06 08:16:28
第一AC 淡意的温柔 591123 2020-06-06 08:16:28
第一挑战 淡意的温柔 591123 2020-06-06 08:16:28

赛题来源/所属竞赛 2019 Multi-University Training Contest 6 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛