UESTC 1852 Traveling Cellsperson
Traveling Cellsperson
64-bit integer IO format: %lld Java class name: Main
You have solved every problem from Project Euler in your head. Now it is time for a problem you might have heard of,namely The Traveling Salesperson, whose decision version is NP-complete. We consider the Traveling Salesperson problem in a 2D rectangular grid where every cell can be reached from their neighboring cells (up,down, left and right) and you can visit a cell as many times as you like (though, most of the cells aren't that interesting, so you might prefer not to visit them a lot).
Input
The first line of the input consists of a single integer T, the number of test cases. Then follow two integers X and Y , marking the width and height of the grid, respectively. Then follow Y lines with X characters, where the character 'C' is a cell and the character 'S' is the starting point.
0 < T <= 50
0 < X <= 100
0 < Y <= 100
All characters in a test case are 'C', except for exactly one, which is 'S'.
Output
For each test case, output the minimum number of steps required to make a full roundtrip of the grid, starting and ending at S, and visiting each cell at least once.
Since you realize that this won't lead anywhere, finish off the output with "LOL"(without quotes) on a line of its own (one per run, not per test case).
Sample Input
1
4 4
CCCC
CCCC
CSCC
CCCC
Sample Output
16
LOL
Source
IDI Open 2013 Programming Contest
|
#include <iostream>
#include <cstring> #include <cstdio> using namespace std; char str[110]; int main() |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )
UESTC 1852 Traveling Cellsperson的更多相关文章
- Traveling by Stagecoach(POJ 2686)
原题如下: Traveling by Stagecoach Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4494 Ac ...
- ACM:UESTC - 649 括号配对问题 - stack
UESTC - 649 括号配对问题 Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & %llu ...
- Traveling in Blade & Soul
Traveling in Blade & Soul Walking is too simple. Having trained their physics and spirits for ye ...
- UESTC 1015 Lweb and pepper --前,后缀最值
题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...
- UESTC 1851 Kings on a Chessboard
状压DP... Kings on a Chessboard Time Limit: 10000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 30 最短路,floyd,水
最短路 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Statu ...
- uestc oj 1218 Pick The Sticks (01背包变形)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...
- uestc oj 1217 The Battle of Chibi (dp + 离散化 + 树状数组)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1217 给你一个长为n的数组,问你有多少个长度严格为m的上升子序列. dp[i][j]表示以a[i]结尾长为j ...
- Traveling by Stagecoach 状态压缩裸题
Traveling by Stagecoach dp[s][v] 从源点到达 v,状态为s,v的最小值. for循环枚举就行了. #include <iostream> #inclu ...
随机推荐
- bash的变量设置
1. myname=zhangsan //设置变量 2. echo $myname //显示变量 或者:echo ${myname} 3. myname="my name is $mynam ...
- C语言:链表实现的一个实例
问题:写一个程序输入你一年看过的所有电影以及每部电影的各种信息(简化问题:每部电影只要求输入片名和评价) 链表实现: #include<stdio.h> #include<stdli ...
- VS2012旗舰版接选择调试 出现了这样一个错误
问题: 解决: 项目-右键-属性,勾选如下配置试试
- 理解和使用 JavaScript 中的回调函数
理解和使用 JavaScript 中的回调函数 标签: 回调函数指针js 2014-11-25 01:20 11506人阅读 评论(4) 收藏 举报 分类: JavaScript(4) 目录( ...
- ef6 缓存的问题没有了
public static void Main(string[] args) { PMTestEntities db = new PMTestEntities(); var users = db.Us ...
- 通过KUDU获取Azure网站的日志
部署到Azure上的website,由于无法通过RDP的方式去登录查看log,所以我们只能通过FTP的方式或者kudu的方式进行查看,具体如下: 1.使用FTP账户和密码登录网站的KUDU界面: 如您 ...
- ecshop 后台模板设置-》设置模板
ecshop后台“设置模板”出现问题 问题1:不能出现特殊符号 / <!-- TemplateBeginEditable name="5F生活数码/手机" -->&l ...
- 使用Alcatraz来管理Xcode插件(转)
转自唐巧的博客:http://blog.devtang.com/blog/2014/03/05/use-alcatraz-to-manage-xcode-plugins/ 简介 Alcatraz是一个 ...
- Spring入门_03_构造注入
实体类 Student.java package com.umgsai.spring.entity; import java.util.Date; public class Student { pri ...
- Mount挂载命令使用方法
语法: mount -t 类型 -o 挂接方式 源路径 目标路径 -t 详细选项: 光盘或光盘镜像:iso9660 DOS fat16文件系统:msdos Windows 9x fat32文件 ...