Gym 101981K bfs】的更多相关文章

思路:暴力让所有的骆驼和第一只骆驼合并,比如现在是第k只骆驼和第一只合并,广搜找出第k只骆驼如果想和第一只骆驼合并需要走哪一步,然后走一步,并更新所有骆驼的位置. 代码: #include <bits/stdc++.h> #define pii pair<int, int> #define INF 0x3f3f3f3f using namespace std; const int maxn = 21; char s[maxn][maxn]; int pre[maxn][maxn];…
题目链接:http://codeforces.com/gym/101981/problem/K Your friend has made a computer video game called “Kangaroo Puzzle” and wants you to give it a try for him. As the name of this game indicates, there are some (at least 2) kangaroos stranded in a puzzle…
题面 题意:给你1个20*20的格子图,有的是障碍有的是怪,你可以每次指定上下左右的方向,然后所有怪都会向那个方向走, 如果2个怪撞上了,就融合在一起,让你给不超过5w步,让所有怪都融合 题解:我们可以选择一个边角的位置,每次都让一个怪移动到那里,同时暴力维护剩下的怪的位置,暴力走就可以了 不过后面发现好像直接随机也能过去? 下面我们队3个人的... #include <iostream> #include<string> #include<cstring> #incl…
Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u  Practice  Description standard input/output Ayutthaya was one of the first kingdoms in Thailand, spanning since its foundation in 1350 to…
E. Two Labyrinths Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/E Description A labyrinth is the rectangular grid, each of the cells of which is either free or wall, and it's possible to move only between free…
F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Description We all know that King Triton doesn't like us and therefore shipwrecks, hurricanes and tsunami do happen. But being bored with the same routine…
F. Contestants Ranking time limit per test:1 second memory limit per test:24 megabytes input:standard input output:standard output Ahmad is one of the best students in HIAST, and also a very good problems Solver. In the time you will spend reading th…
http://codeforces.com/gym/101617/attachments 题意:给出一个图,每个顶点代表一个金矿,每个金矿有g和d两个值,g代表金矿初始的金子量,d是该金矿每天的金子量会减少d.顶点与顶点之间存在边,意思是从一个金矿到另一个金矿需要花费的天数.现在有个人一开始在1金矿,问最多能挖到多少金矿,注意,不能在一个金矿连续挖几天. 思路:bfs求解,但是需要剪枝,用二位数组d[v][day]记录第day天时在v金矿所能获得的最大值. #include<iostream>…
题目链接:http://codeforces.com/gym/100971/problem/J J. Robots at Warehouse time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output Vitaly works at the warehouse. The warehouse can be represented as a grid of n ×…
题目链接:http://codeforces.com/gym/101147/problem/E 题意:当人在第i个商店时,他可以向左或向右跳di段距离到达另一个商店(在范围之内),一个商店为一段距离.问:对于每一个商店,跳到最后一个商店最少需要跳几次? 题解:题目实际上是求最短距离,而且边权为1,所以可以直接用bfs.由于是求每个点到最后一个点的最短距离,那么可以反向建图,将最后一个点设为起始点,然后向前跑.对于跑不到的点,回到题目上说,实际就是这个商店不能到达最后一个商店. 代码如下: #in…