数字的迷宫的寻路的算法解决,怎么采用c程序的语言编写的技术实现的呢?

Problem Description
Slitherlink is a type of logic puzzle made popular by Nikoli, the same Japanese puzzle company that has made Sudoku popular the world over. Like
most good logic puzzles, it has a set of very basic rules that can nonetheless result in devilishly difficult (and delightful!) puzzling experiences.

The rules of Slitherlink are as follows:

A Slitherlink board is made up of a lattice of dots; in this problem, it will be a regular rectangular lattice.
Some of the boxes (or cells) defined by the lattice have numbers within them; with a regular rectangular lattice, the numbers will be between 0
and 3 inclusive.
The goal of a Slitherlink puzzle is to connect adjacent dots (horizontally or vertically, like the sides of boxes) so that there is a single loop that
never crosses itself, with no line segments that are not part of the loop (no "dangling" segments or other, separate loops) such that every cell
that has a number has exactly that many sides as segments of the loop.

Given a supposedly solved Slitherlink puzzle, your task will be to determine whether or not it is indeed legitimately solved.

Input
Input to this problem will begin with a line containing a single integer N (1 ≤ N ≤ 100) indicating the number of data sets. Each data set consists of
the following components:

A line containing two integers H, W (1 ≤ H,W ≤ 20) representing the height and width of the Slitherlink puzzle by the number of cells (not
dots!) per edge;
A series of 2H + 1 lines representing the Slitherlink puzzle, using the following non-whitespace characters:
0, 1, 2, 3, ?: The numbers written inside a given cell. A ? represents an empty cell, as in the example graphic above.
#: A dot in the lattice.
-, |: A horizontal or vertical line segment.
.: An empty adjacency between two dots in the lattice.

Note that all Slitherlink puzzles will be fully represented; that is, there is no internal whitespace on a given line to represent empty cells or
adjacencies.

Output
For each data set, print "VALID" if the solution is a valid solution to the given Slitherlink, or "INVALID" if the solution is not valid.

Sample Input
2
5 5
#-#-#-#-#-#
|?.?.?.1.3|
#.#-#-#.#-#
|?|?.?|?|?.
#-#.#.#.#-#
.2.0.2|?.?|
#-#.#-#.#-#
|?|3|?.?|2.
#.#-#.#-#.#
|?.?.2|?.0.
#-#-#-#.#.#
5 5
#-#-#-#-#-#
|?|?.?.1.3|
#.#-#-#.#-#
|?|?.?|?|?.
#-#.#.#.#-#
.2.0.2|?.?|
#-#.#-#.#-#
|?|3|?.?|2.
#.#-#.#-#.#
|?.?.2|?.0.
#-#-#-#-#.#

Sample Output
VALID
INVALID

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

相似问题

1
QT 迷宫游戏 可视化迷宫
1
问题 C: 孤岛营救问题【队列 搜索 BFS】。
2
vc++写的一个小球迷宫的小游戏,没有错误,但是无法运行,就是打开后显示exe文件无法运行
0
C++迷宫(栈实现),无法回溯
1
用java写的迷宫,能够打开自己制定的迷宫地图,并找出最短路径和遍历迷宫
1
骑士游历C语言版,用类似迷宫算法如下,求大神告知错误的地方。
0
用栈解决迷宫问题不知为什么大的例子跑不出
2
c语言走迷宫问题提问!
1
我有一个代码,能不能帮我把里面的swing和awt改成JavaFx,急需。联系QQ3246798340,可rmb报酬
0
这是我写的迷宫问题的代码,请问各位大神为什么最后输出不了迷宫通路呀
0
用Java做算法提高 学霸的迷宫
1
一个数据结构上面路径可达性判断的问题,要求采用C语言技术
0
一个迷宫是否联通的有效性的判定算法怎么实现,采用C语言编程怎么实现
1
BFS走迷宫传送门超时怎么改进啊?
0
迷宫的遍历的算法在数据结构方面的一个运用,怎么采用C程序的语言的技术设计的代码实现?
0
c语言,迷宫问题,救救孩子
2
为什么到最后一直无法输出迷宫路径?
0
迷宫的绕路的一个算法问题,如何运用C语言的程序的编写的方式实现
0
数组走到右上角时可以获得的最大金币数目,请问怎么样才能使用C语言的程序的编写的技术实现的?
0
一个迷宫的便利的典型的算法问题,怎么利用C语言程序代码思路解题的过程?