数据水了。。。

不知道正解是什么

将TOM放在一个0上经过输入的  1 2 R 这样走 还能在图上则这个点可行(走的过程中不能走出图)

求有几个0 可行

直接dfs 完全没有别的思路

题目要求必须 走 A - B 步 所以在走A步不能遇到 1

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cctype>
#include <cmath>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
typedef long long LL;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define pi acos(-1.0)
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
typedef pair<int, int> PI;
typedef pair<int, PI> PP;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
//LL quick(LL a, LL b){LL ans=1;while(b){if(b & 1)ans*=a;a=a*a;b>>=1;}return ans;}
inline int read()
{char ch=' ';int ans=0;while(ch<'0' || ch>'9')ch=getchar();while(ch<='9' && ch>='0'){ans=ans*10+ch-'0';ch=getchar();}return ans;
}
//inline void print(LL x){printf(LLD, x);puts("");}
bool mp[105][105];
PP step[1005];
int d, m, n;
bool solve(int r, int c,int x)
{if(r>=m || c>=n)return false;if(r<0 || c<0)return false;if(x==d)if(!mp[r][c])return true;else return false;int a=step[x].second.first;int b=step[x].second.second;//bool flag=0;if(step[x].first==0){for(int i=c-1; i>=c-a; i--){if(i<0)return false;if(mp[r][i])return false;}for(int i=c-a; i>=c-b; i--){if(solve(r,i,x+1))return true;}}if(step[x].first==1){for(int i=c+1; i<=c+a; i++){if(i>=n)return false;if(mp[r][i])return false;}for(int i=c+a; i<=c+b; i++){if(solve(r,i,x+1))return true;}}if(step[x].first==2){for(int i=r-1; i>=r-a; i--){if(i<0)return false;if(mp[i][c])return false;}for(int i=r-a; i>=r-b; i--){if(solve(i,c,x+1))return true;}}if(step[x].first==3){for(int i=r+1; i<=r+a; i++){if(i>=m)return false;if(mp[i][c])return false;}for(int i=r+a; i<=r+b; i++){if(solve(i,c,x+1))return true;}}return false;
}
int main()
{
#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);
#endifint t=read();while(t--){m=read(), n=read();for(int i=0; i<m; i++)for(int j=0; j<n; j++)mp[i][j]=read();d=0;while(true){int a=read(), b=read();if(a==0 && b==0)break;char op[2];int c;scanf("%s", op);if(op[0]=='L')c=0;else if(op[0]=='R')c=1;else if(op[0]=='U')c=2;else if(op[0]=='D')c=3;step[d++]=make_pair(c, make_pair(a, b));}int ans=0;for(int i=0; i<m; i++)for(int j=0; j<n; j++)if(!mp[i][j])if(solve(i, j,0))ans++;printf("%d\n", ans);}return 0;
}

转载于:https://www.cnblogs.com/kewowlo/p/4088355.html

【DFS】HDU 1364 POJ 1071 Illusive Chase相关推荐

  1. 【DFS】 HDU 3298 Contestants

    随便以一个点为根 计算其子树和自己本身的点值 然后枚举已切每个点的ans取最小值 #include <stdio.h> #include <string.h> #include ...

  2. Bailian2815 城堡问题【DFS】

    2815:城堡问题 总时间限制: 1000ms 内存限制: 65536kB 描述 1 2 3 4 5 6 7 ############################# 1 # | # | # | | ...

  3. Bailian2816 红与黑【DFS】

    2816:红与黑 总时间限制: 1000ms 内存限制: 65536kB 描述 有一间长方形的房子,地上铺了红色.黑色两种颜色的正方形瓷砖.你站在其中一块黑色的瓷砖上,只能向相邻的黑色瓷砖移动.请写一 ...

  4. NUC1158 Lake Counting【DFS】

    Lake Counting 时间限制: 1000ms 内存限制: 65536KB 通过次数: 1总提交次数: 1 问题描述 Due to recent rains, water has pooled ...

  5. NUC1399 Sum It Up【DFS】

    Sum It Up 时间限制: 1000ms 内存限制: 65535KB 通过次数: 1总提交次数: 1 问题描述 Given a specified total t and a list of n ...

  6. [kuangbin]专题三 Dancing Links Squiggly Sudoku HDU - 4069【DFS】【精确覆盖】

    [题目描述] Today we play a squiggly sudoku, The objective is to fill a 9*9 grid with digits so that each ...

  7. HDU1181 变形课【DFS】(废除)

    新题解参见:HDU1181 变形课[DFS+关系闭包+bitset] 变形课 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 13107 ...

  8. 【DFS】巧妙取量的倒油问题

    题目描述 [题目描述]  有三个容器,容量分别为 a,b,c(a> b > c ),一开始a装满油,现在问是否只靠abc三个容器量出k升油.如果能就输出"yes",并且 ...

  9. 【数学】HDU 5761 Rower Bo

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 题目大意: 船在(0,a),船速v1,水速v2沿x轴正向,船头始终指向(0,0),问到达(0, ...

最新文章

  1. 单片机中的ROM,RAM和FLASH的作用
  2. Linux命令(32):rar命令-解压
  3. ajax往CJJTable传值,jQuery+ajax怎么样实现动态数据分页
  4. python免费试听-小栈春季编程免费试听课 倒数6天!
  5. [Tips]Torch功能点记录
  6. gets函数会读取回车吗_会做二次函数吗?用6种方法教你做二次函数(初中生不要错过)...
  7. Windows开发时IsWindowVisible返回错误的处理方法
  8. java项目连接jboss中数据库_月光软件站 - 编程文档 - Java - JBOSS3.2.5中MYSQL数据库连接池的建立与测试...
  9. 2020年,为什么你该学PHP?!!
  10. 类/对象/构造函数/析构函数
  11. 常见排序算法之快速排序
  12. 安卓磁链搜索下载播放和原理探索
  13. vscode自动补全c语言_vscode代码自动补全失效
  14. dtools: error while loading shared libraries: libicui18n.so.55: cannot open shared object file
  15. NSA互联网公开情报收集指南:迷宫中的秘密·下
  16. 1044 火星数字(C语言)
  17. 极客时间前端进阶特训营winter、杨村长、然叔、高少云,《精通React》大专栏,React低代码项目,前端算法实战,杨村长Vue3开源组件库实战(Vue3+Vite+VitePress+TSX+T
  18. 桩基施工市场现状研究分析报告-
  19. keras实现LFW测试
  20. VNC树莓派无法连接

热门文章

  1. 1.springboot:入门程序
  2. vue-i18n使用及踩坑记录
  3. (翻译)31天Windows Phone学习-1-项目模板
  4. Win10 IIS本地部署网站运行时图片和样式不正常?
  5. H.264可伸缩编码SVC
  6. SQL SERVER自定义函数
  7. 6月份Asp.net源码推荐
  8. 使用CodeSmith要注意的几点
  9. 网络爬虫--22.【CrawlSpider实战】实现微信小程序社区爬虫
  10. 2017计算机考试题上机,2017年计算机二级上机考试试题及答案