一个有关安于邻接矩阵的问题,是如何利用C语言编程实现的呢

Problem Description
While visiting a traveling fun fair you suddenly have an urge to break the high score in the Whac-a-Mole game. The goal of the Whac-a-Mole game is to… well… whack moles. With a hammer. To make the job easier you have first consulted the fortune teller and now you know the exact appearance patterns of the moles.

The moles appear out of holes occupying the n2 integer points (x, y) satisfying 0 ≤ x, y < n in a two-dimensional coordinate system. At each time step, some moles will appear and then disappear again before the next time step. After the moles appear but before they disappear, you are able to move your hammer in a straight line to any position (x2, y2) that is at distance at most d from your current position (x1, y1). For simplicity, we assume that you can only move your hammer to a point having integer coordinates. A mole is whacked if the center of the hole it appears out of is located on the line between (x1, y1) and (x2, y2) (including the two endpoints). Every mole whacked earns you a point. When the game starts, before the first time step, you are able to place your hammer anywhere you see fit.

Input
The input consists of several test cases. Each test case starts with a line containing three integers n, d and m, where n and d are as described above, and m is the total number of moles that will appear (1 ≤ n ≤ 20, 1 ≤ d ≤ 5, and 1 ≤ m ≤ 1000). Then follow m lines, each containing three integers x, y and t giving the position and time of the appearance of a mole (0 ≤ x, y < n and 1 ≤ t ≤ 10). No two moles will appear at the same place at the same time.

The input is ended with a test case where n = d = m = 0. This case should not be processed.

Output
For each test case output a single line containing a single integer, the maximum possible score achievable.

Sample Input
4 2 6
0 0 1
3 1 3
0 1 2
0 2 2
1 0 2
2 0 2
5 4 3
0 0 1
1 2 1
2 4 1
0 0 0

Sample Output
4
2

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

0
查找最近的车站的一个算法问题,采用邻接矩阵的方式的表述,怎么计算的,运用C语言的相关知识
0
用邻接表实现距离数组的存储的计算,用C语言的程序编写的方法如何解决
1
用数组表示法(邻接矩阵)和邻接表两种存储结构分别表示下面的无向图。
1
有向图,证明顶点数和完成时间
1
给出一个有向图,证明是否存在顶点且可在时间内完成出度
2
数据结构图(用C语言)当中为什么邻接表用结构体变量报错,用邻接矩阵不报错?
1
c语言,建立无向图进行广度优先遍历产生问题
1
编程实现有向图的深度和广度优先遍历
0
用邻接矩阵创建有向网,求最小生成树,最短路径(c语言)。
1
求教大佬们,这个“读取位置 0xCCCCCCCC 时发生访问冲突。”的异常该如何解决?
1
C#调用纯C的DLL时,结构体指针、数组、二维数组 怎么转换?
0
在Windows7 64位+VS2015上运行求解AOE网关键路径的算法,邻接表表示的AOE网提示网中有回路,邻接矩阵表示的AOE网显示正确的信息?使用的算法是一样的,两种方法的相关类的接口函数也一致,为什么会出现这种问题?
1
用c语言版写的求解关键路径,调试到一半按任意键继续就关了,求大神看看我的代码
0
floyd算法求任意两点最短路径,为什么输出的邻接矩阵总不正确
0
利用普利姆算法和克鲁斯卡尔算法实现最小生成树问题C语言或者C++语言实现
1
c语言实现的套汇问题 钱的种类多了就就不行了
1
局部聚类系数求法-用java 编程,图用邻接矩阵表示
2
请问有没有一种 O(V+E)的算法可以判断给定的一个图的邻接链表是否存在任何平行边?(判断这个邻接链表的图是否属于多重图)
2
设计一种O(V+E)的算法来将给定的一个图的邻接链表中包含的顶点按由小到大的顺序排列。