ZOJ Problem Set
来源:互联网 发布:js的单选按钮的事件 编辑:程序博客网 时间:2024/06/05 09:56
ZOJ Problem Set - 2100
题意:一块田地,播种机从左上出发,不能重复走,不能走石头。判断能不能。
思路:简单的dfs。
细节:走过的标记成石头,不行就改回来。
#include <iostream>#include <cstdio>#include <cstring>using namespace std;int n, m;char a[10][10];int num , flag;void dfs(int x, int y){ if(x < 1 || x > n || y < 1|| y > m) return; if(a[x][y] == 'S') return; num++; a[x][y] = 'S'; if(num == n*m){ flag = 1;return; } dfs(x+1, y); dfs(x-1, y); dfs(x, y+1); dfs(x, y-1); num--; a[x][y] = '.';}int main(){ while(cin >> n >> m && n && m){ num = 0; flag = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++){ cin >> a[i][j]; if(a[i][j] == 'S') num++; } dfs(1,1); if(flag) cout << "YES" << endl; else cout << "NO" << endl; }}
阅读全文
0 0
- ZOJ Problem Set - 2060
- ZOJ Problem Set - 2972
- ZOJ Problem Set - 1037
- ZOJ Problem Set - 1048
- ZOJ Problem Set - 1049
- ZOJ Problem Set - 1051
- ZOJ Problem Set - 1067
- ZOJ Problem Set - 1115
- ZOJ Problem Set - 1151
- ZOJ Problem Set - 1205
- ZOJ Problem Set - 1025
- ZOJ Problem Set - 1029
- ZOJ Problem Set - 1076
- ZOJ Problem Set - 1117
- ZOJ Problem Set - 1041
- ZOJ Problem Set - 1004
- ZOJ Problem Set - 1005
- ZOJ Problem Set - 1016
- Appium 新手学 appium-Appium for Windows 说明 (中文翻译)
- Android项目里的图片轮换
- A Deep Learning-Based Segmentation Method for Brain Tumor in MR Images-阅读笔记
- 数据分析(入门篇)-第二章-玩转数据分析-Part3(Excel数据分析工具库-直方图)
- Spring通过注解@Value获取properties配置
- ZOJ Problem Set
- UVA 514 判断一列数的顺序是否能用栈而排列出
- 3453. 【NOIP2013中秋节模拟】连通块(connect)
- 欢迎使用CSDN-markdown编辑器
- would you like to 和would you like
- jzoj 1731. 【10.5NOIP普及模拟】sum(sum.pas/cpp)
- 169. Majority Element
- CXF添加自定义拦截器
- 神经网络-激活函数-Activation