红黑瓷砖问题
BFS广度优先搜索。来源hdu1312
问题描述:
编写一个程序,通过重复上述移动来计算他可以达到的黑色瓷砖
数量。
输入:
数据集中有更多的行,其中每个行都包含 W
字符。每个字符表示磁贴的颜色如下。"。"-黑色
瓷砖"#"-红色瓷砖
'@'-黑瓦上的人(在数据集中正好出现一次)
输出:
先将前置的类声明
#include<stdc++.h>
万能头文件,在include文件夹中添加<stdc++.h>文件,可以省略很多文件的声明。
该问题的难点在于如何判断每一段的公共子序列是否一致。先从声明字符串的长度起始,判断第一项的最长子序列。
代码如下:
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or