LETTERS

http://poj.org/problem?id=1154

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

6



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
这道题不是多组输入,只是单组输入,如果写成多组输入后就会出现Output Limit Exceeded,这应该算是一篇比较简单dfs,代码中的一大亮点是map标记数组的应用,很精奥。
#include<stdio.h>
#include<string.h>
#define NN 30
#define MAX(a,b) (a)>(b)?(a):(b)
int m,n,ans;
char huiyao[NN][NN];
int ope[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int map[27];
void dfs(int x,int y,int step)
{
int xl,yl,l;
ans=MAX(ans,step);
map[huiyao[x][y]-'A']=0;
for(l=0;l<4;l++)
{
xl=x+ope[l][0];
yl=y+ope[l][1];
if(xl<0||yl<0||xl>=m||yl>=n)
    continue;
if(map[huiyao[xl][yl]-'A']==0)
   continue;
        map[huiyao[xl][yl]-'A']=0;
        dfs(xl,yl,step+1);
        map[huiyao[xl][yl]-'A']=1;
}

}
int main()
{
int i,j,k;
scanf("%d%d",&m,&n);

getchar();
memset(map,0,sizeof(map));
for(i=0;i<m;i++)
scanf("%s",huiyao[i]);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
map[huiyao[i][j]-'A']=1;
}
}
ans=1;
dfs(0,0,1);
printf("%d\n",ans);
/*for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%c",huiyao[i][j]);
}
printf("\n");
}*/
return 0;
}

### 关于 Transportation Letters in Computer Science Context 在计算机科学领域中,“Transportation Letters”通常指的是专注于交通系统建模、分析和优化的研究期刊或论文集。这些研究涉及多个学科交叉,包括但不限于运筹学、人工智能、数据挖掘以及网络理论等[^1]。 #### 论文与资源检索方法 为了找到关于交通运输领域的相关文献,在学术数据库中的关键词组合可以采用如下形式:“transportation systems”,“traffic management”,或者更具体的主题如“intelligent transportation systems (ITS)”。此外,还可以通过访问知名出版平台来获取最新研究成果,例如 IEEE Xplore Digital Library 和 SpringerLink 中均收录大量高质量文章。 对于希望深入理解该领域专业知识的人来说,除了阅读顶级会议(如 TRB Annual Meeting Proceedings)上的高水平报告外,也可以关注一些专门讨论智能运输系统的国际期刊,比如《IEEE Transactions on Intelligent Transportation Systems》或是提问者提到的可能存在的《Journal of Information Science》相关内容。 以下是 Python 脚本示例用于自动化搜索特定条件下的 SCI/SSCI 文献列表: ```python import requests from bs4 import BeautifulSoup def search_transportation_papers(keyword, num_results=5): base_url = f"https://www.example-sci-search.com/?q={keyword}&num={num_results}" response = requests.get(base_url) soup = BeautifulSoup(response.text, 'html.parser') papers = [] for item in soup.find_all('div', class_='paper-item'): title = item.find('h3').text.strip() link = item.find('a')['href'] abstract = item.find('p', class_='abstract').text.strip()[:200] + "..." paper_info = { "title": title, "link": link, "abstract": abstract } papers.append(paper_info) return papers if __name__ == "__main__": results = search_transportation_papers("transportation letters", 3) for idx, result in enumerate(results, start=1): print(f"{idx}. {result['title']}\n{result['abstract']} More at [{result['link']}]({result['link']})\n") ``` 此脚本仅为示意用途,请根据实际使用的搜索引擎调整 URL 及 HTML 解析逻辑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值