zoj 3865】的更多相关文章

题目传送门 /* BFS+模拟:dp[i][j][p] 表示走到i,j,方向为p的步数为多少: BFS分4种情况入队,最后在终点4个方向寻找最小值:) */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <queue> using namespace std; ; cons…
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3865 思路 一个迷宫题 但是每次的操作数和普通的迷宫题不一样 0.按下按钮 即向当前方向盘的方向前进一格 1.往左移动方向盘 2.往右移动方向盘 3.不动 然后记录时间 易知,可以从四个方向到达终点,最后从这四个方向找最小值就是答案 当然要判断 不能通达的结果 AC代码 #include <cstdio> #include <cstring> #i…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5477 主要思路:1.从一个点(cur)到它相邻的点(next),所需要的时间数(t)其实是固定的,而且这个移动过程后,到达next时,相应的方向也是固定的,找到求t的办法就好了.    2.到达一个未到达的点可能有多条路,优先队列取时间最短的路,则答案最优 题目: Superbot Superbot is an interesting game which you…
Superbot Time Limit: 2 Seconds      Memory Limit: 65536 KB Superbot is an interesting game which you need to control the robot on an N*M grid map. As you see, it's just a simple game: there is a control panel with four direction left (1st position),…
按规则移动机器人 , 问是否能拾得宝藏 . 加了一个控制板 , 还增加了一个控制板移动周期 p 将移动周期变换一下 , 移动一次  就相当于光标向左不耗费时间的移动了一格 搜索思路 : 搜索当前格子到上下左右四个格子所花费的最短时间 . 记录光标的信息 , 和当前格子所需最短时间 . bfs + bfs #include <bits/stdc++.h> using namespace std; #define PI acos(-1.0) #define MAXN 20 #define INF…
不知道为什么比赛的时候一直想着用DFS 来写 一直想剪枝结果还是TLE = = 这题数据量不大,又是问最优解,那么一般来说是用 BFS 来写 int commandi[4] = {1, 2, 3, 4}; 我定义了一个方向数组,其实题目意思中的,指针移动还有操作版的变化本质上都是指针的移动 在此只需要 额外定义一个变量 cur 在数组 commandi 中循环移动即可 这道题目还是因为数据量不大吧,直接用 STL 中的 Queue 即可,优先队列肯定会更快. 总体来说,还是一道容易题. Sour…
Superbot Time Limit: 2 Seconds      Memory Limit: 65536 KB Superbot is an interesting game which you need to control the robot on an N*M grid map. As you see, it's just a simple game: there is a control panel with four direction left (1st position),…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5477 大牛博客:http://www.cnblogs.com/kylehz/p/4420009.html 只不过状态用vis[20][20][4]来记录,每个点都有四个状态,访问过就不能访问 通过控制面板控制机器人找钻石,控制面板每p时间右移一次(队尾变队首),求最短路径 控制面板为左右上下的顺序,初始时 光标在左 有3种操作,占用一个单位时间 1. 光标左移(最左的移到最右…
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3944 In a BG (dinner gathering) for ZJU ICPC team, the coaches wanted to count the number of people present at the BG. They did that by having the waitre…
A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of operation: given a subtree, negate all its labels. An…