poj 3182 The Grove bfs】的更多相关文章

思路:如果要围绕一圈,必须经过一条竖线上的一点,把竖线左端封住,bfs一次,枚举点,再把竖线右端封住,再bfs回起点. #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=5e1+9,inf=1e9; char a[maxn][maxn],now[maxn][maxn]; int dist[maxn][maxn],d[maxn][maxn…
The Grove Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 641   Accepted: 297 Description The pasture contains a small, contiguous grove of trees that has no 'holes' in the middle of the it. Bessie wonders: how far is it to walk around t…
题意: 给一个地图,给定起点和一块连续图形,走一圈围住这个图形求最小步数 本来是要做课件上一道$CF$题,先做一个简化版 只要保证图形有一个点在走出的多边形内就可以了 $hzc:$动态化静态的思想,假设已经有了路线怎么判断合法 点在多边形内是“点变多边形不变”,我们反过来维护多边形变 $f[i][j][0/1]$表示当前走到$(i,j)$,点是否在多边形内 维护一条向右发出的射线,每次走的时候看看有没有穿过射线就行了 因为这是个网格,我们可以规定只有从上面经过才算穿过 然后,这不是$DAG$啊怎…
//yy:昨天看着这题突然有点懵,不知道怎么记录路径,然后交给房教了,,,然后默默去写另一个bfs,想清楚思路后花了半小时写了120+行的代码然后出现奇葩的CE,看完FAQ改了之后又WA了.然后第一次用对拍去找特殊数据折腾到十二点半终于AC,最后只想感叹没有仔细读题,没办法啊看着英语略烦躁,不扯了,那个题题解不想写了,回到这题...今天中午还是花了四十分钟写了这题(好慢啊orz),感觉,啊为什么别人可以一下子就写出来,我却想不到怎么写呢!!! poj 3414 Pots  [BFS] 题意:两个…
P2864 [USACO06JAN]树林The Grove(bfs) 题面 题目描述 The pasture contains a small, contiguous grove of trees that has no 'holes' in the middle of the it. Bessie wonders: how far is it to walk around that grove and get back to my starting position? She's just s…
题意:一个n*m(n,m<=50)的矩阵有一片连着的树林,Bessie要从起始位置出发绕林子一圈再回来,每次只能向横着.竖着或斜着走一步.问最少需多少步才能完成. /* 如果我们用搜索来写的话,如果搜出的路径能够包围其中的一个点,那么就能包围森林,这样问题就被简化了. 我们任选一个点作为被包围点,在搜索时利用射线原理判断某这个点是否在多边形中(判断函数需要认真考虑). 如果这条射线经过多边形奇数次,则在多边形内,否则不在. */ #include<cstdio> #include<…
http://poj.org/problem?id=3026 Borg Maze Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3026 Description The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of…
  fengyun@fengyun-server:~/learn/acm/poj$ cat 1979.cpp #include<cstdio> #include<iostream> #include<string> #include<algorithm> #include<iterator> #include<sstream>//istringstream #include<cstring> #include<que…
题目:http://poj.org/problem?id=3414 题意:给出了两个瓶子的容量A,B, 以及一个目标水量C, 对A.B可以有如下操作: FILL(i)        fill the pot i (1 ≤ i ≤ 2) from the tap; DROP(i)      empty the pot i to the drain; POUR(i,j)    pour from pot i to pot j; after this operation either the pot…
题目:http://poj.org/problem?id=3126 题意:给定两个四位数,求从前一个数变到后一个数最少需要几步,改变的原则是每次只能改变某一位上的一个数,而且每次改变得到的必须是一个素数: #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack> #include<queue> #include<…