题目1091:棋盘游戏
来源:互联网 发布:跳跃网络300tank是什么 编辑:程序博客网 时间:2024/05/29 17:42
#include <iostream>#include <algorithm>#include <queue>#include <vector>#include <cstring>#include <stack>#include <string>#include <string.h>#include <stdio.h>#include <cmath>#include <map>#include <functional>#include <set>#include <limits.h>#include <math.h>#include <ctype.h>using namespace std;//1091int mp[6][6];bool mark[6][6];int k,sx,sy,ex,ey,sum,sta,mi;int go[][2]={{-1,0},{1,0},{0,-1},{0,1}};void dfs(int sx,int sy,int sum,int sta){ if(sum<mi) { if(sx==ex && sy==ey){ mi=sum; return; } for(int i=0;i<4;i++) { int tx=sx+go[i][0],ty=sy+go[i][1]; if(tx>=0 && tx<6 && ty>=0 && ty<6 && !mark[tx][ty]) { mark[tx][ty]=true; int t= mp[tx][ty]*sta; dfs(tx,ty,sum+t,t%4+1); mark[tx][ty]=false; } } } } int main(){ //freopen("input.txt","r",stdin); cin>>k; while(k--) { for(int i=0;i<6;i++) for(int j=0;j<6;j++) { cin>>mp[i][j]; mark[i][j]=false; } cin>>sx>>sy>>ex>>ey; mi=123123123; dfs(sx,sy,0,1); cout<<mi<<endl; } return 0;}/************************************************************** Problem: 1091 User: cust123 Language: C++ Result: Accepted Time:10 ms Memory:1520 kb****************************************************************/
0 0
- 题目1091:棋盘游戏
- 题目1091:棋盘游戏
- 九度题目1091:棋盘游戏
- 九度OJ--题目1091:棋盘游戏
- 题目1091:棋盘游戏 -- DFS BFS
- 九度 oj 题目1091:棋盘游戏
- 1091_棋盘游戏
- 九度[1091]-棋盘游戏
- 棋盘游戏
- 棋盘游戏
- 棋盘游戏
- 棋盘游戏
- 棋盘游戏
- 棋盘游戏
- 棋盘游戏
- 棋盘游戏
- 九度OJ(1091)棋盘游戏
- 九度OJ 1091 棋盘游戏
- c++ 小数的四舍五入
- 冒泡排序&选择排序
- 阿里巴巴java开发手册一方库、二方库、三方库都是什么
- Ubuntu常用快捷键
- WebSocket之解析数据帧
- 题目1091:棋盘游戏
- 效率(3)PPT
- 数据结构与算法学习笔记第一天--什么是数据结构
- 前端学习笔记
- 邮件发送(一)
- appium与自动化测试(三) 一个基于python的appium例子
- #tensorflow学习笔记#tf.gather
- BZOJ 3626 [LNOI2014]LCA
- 借助Stetho在Chrome上调试Android网络、数据库、Sharedpreferences