C++搜尋與回溯演算法之LETTERS(字母)
LETTERS(字母)
Description
A single-player game is played on a rectangular board divided in R rows and C columns. There is a single uppercase letter (A-Z) written in every position in the board.Before the begging of the game there is a figure in the upper-left corner of the board (first row, first column). In every move, a player can move the figure to the one of the adjacent positions (up, down,left or right). Only constraint is that a figure cannot visit a position marked with the same letter twice.
The goal of the game is to play as many moves as possible.
Write a program that will calculate the maximal number of positions in the board the figure can visit in a single game.
Input
The first line of the input contains two integers R and C, separated by a single blank character, 1 <= R, S <= 20.The following R lines contain S characters each. Each line represents one row in the board.
Output
The first and only line of the output should contain the maximal number of position in the board the figure can visit.Sample Input
3 6 HFDFFB AJHGDH DGAGEH
Sample Output
相關文章
- C++搜尋與回溯演算法之Lake Counting(數湖)C++演算法
- 劍指offer計劃20( 搜尋與回溯演算法中等)---java演算法Java
- 尋路之 A* 搜尋演算法演算法
- elasticsearch演算法之搜尋模型(一)Elasticsearch演算法模型
- 【Leetcode 346/700】79. 單詞搜尋 【中等】【回溯深度搜尋JavaScript版】LeetCodeJavaScript
- Python之 常用查詢演算法:最小項搜尋、順序搜尋、二分搜尋Python演算法
- [演算法之回溯演算法]演算法
- 高階搜尋演算法之迭代加深演算法
- 資料結構與演算法 排序與搜尋資料結構演算法排序
- 資料結構與演算法 - 排序與搜尋資料結構演算法排序
- 常用演算法之回溯法演算法
- 「演算法之美系列」遞迴與回溯(JS版)演算法遞迴JS
- JAVA圖搜尋演算法之DFS-BFSJava演算法
- c++ 廣度優先搜尋(寬搜)C++
- A*搜尋演算法概述演算法
- 經典演算法之回溯法演算法
- elasticsearch之拼音搜尋Elasticsearch
- js之搜尋框JS
- A*搜尋演算法(python)演算法Python
- 演算法總結--搜尋演算法
- 關於google搜尋欄首字母粘連問題Go
- 演算法之搜尋(Java版)-持續更新補充演算法Java
- 回溯演算法之復原IP地址演算法
- #演算法#二分搜尋演算法
- 回溯演算法演算法
- c++迷宮問題回溯法遞迴演算法C++遞迴演算法
- 看動畫學演算法之:二叉搜尋樹BST動畫演算法
- 搜尋引擎與前端SEO前端
- Android程式設計師面試會遇到的演算法(part 3 深度優先搜尋-回溯backtracking)Android程式設計師面試演算法
- 五大常用演算法之四:回溯演算法演算法
- 搜尋中常見資料結構與演算法探究(二)資料結構演算法
- 啟發式搜尋的方式(深度優先,廣度優先)和 搜尋方法(Dijkstra‘s演算法,代價一致搜尋,貪心搜尋 ,A星搜尋)演算法
- 必知必會JVM垃圾回收——物件搜尋演算法與回收演算法JVM物件演算法
- Sunday搜尋演算法實現演算法
- BM搜尋演算法C實現演算法
- 【演算法】深度優先搜尋(DFS)演算法
- 淘寶搜尋演算法現狀分析演算法
- 基本演算法——深度優先搜尋(DFS)和廣度優先搜尋(BFS)演算法