自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 收藏
  • 关注

原创 POJ 3984迷宫问题(记录路径)

题目大意:题目本身是最简单的BFS,难点是记录路径#include #include #include using namespace std;struct NODE //记录现在所处节点 父亲节点 及步数{ int x, y, step; int prex, prey;}node[10][10];int a[10][10];int dx[] = {0,

2015-09-05 16:27:22 235

原创 POJ 3414 Pots

题目大意:有两个容量分别为a,b的杯子,需要经过若干次变换使任意一个杯子的容量为c,求最短的变换路径#include #include #include using namespace std;int a,b,k;int vis[105][105];struct node{ int x,y,step; string path;};string p[] =

2015-09-05 16:16:54 251

原创 POJ 3278 Catch That Cow

第一次用BFS的方法去做模拟题,值得纪念。#include #include #include using namespace std;int n, k;int vis[200000];struct node{ int x; int step;};int BFS(){ queue q; node cur; cur.x = n;

2015-08-15 22:31:08 205

原创 POJ 3126 Prime Path

题目大意:给定两个素数a,b, 要求每次改变a中的一个数得到一个新的素数a1,再对a1中的一个数改变得到新的素数a2,问循环下去能否得到素数b.思路:BFS 每次改变当前素数的一个值,判断是否为素数即可,注意前导0的问题#include #include #include using namespace std;bool is_prime[10000];int n,

2015-08-15 22:24:05 177

原创 POJ 3087 Shuffle'm Up

题目大意:有两个长度为K的字符串S1,S2,两个字符串的字符交叉放置组成新的长为2*k的字符串s3,与题目给出的S相比较,若不相同,s3的前K个字符重新组成s1,剩余的组成s2,继续循环,若最终能和S相同,输出所需步数,不可行则输出impossible.思路:用模拟做就行了,虽然这题放在模拟专题里,但是只有一个入口,用BFS意义不大。#include #inclu

2015-08-15 22:16:25 214

原创 POJ 2251 Dungeon Master

题目大意:三维的迷宫问题思路:与二维的类似仍用BFS求解,只不过入口由四个变为六个。#include #include #include #include using namespace std;struct node{ int x, y, z, step;};int dx[] = {0,0,-1,1,0,0};int dy[] = {1,-1,0

2015-08-15 22:11:48 159

原创 POJ 1321 棋盘问题

点击打开链接类似于八皇后问题,DFS入门题#include #include #include using namespace std;int n, k;char str[10][10];int a[10][10], cnt, vis[10];void DFS(int cur,int num){ for (int i = 0; i != n;

2015-08-15 22:09:55 173

原创 HDU 1978 How many ways

点击打开链接思路:DFS + DP#include #include #include #include using namespace std;int dp[105][105], a[105][105];int n,m;int dfs(int i, int j){ if (dp[i][j] > 0) return dp[i][j]

2015-08-15 22:03:04 173

原创 HDU 1078 FatMouse and Cheese

题目大意:从(0,0)点开始走,每次垂直或水平行走K步,下一步所获得的价值必须比当前步的价值要大,问所能获得的最大价值。思路:DFS+DP#include #include #include using namespace std;/*DFS + DP */int a[105][105], dp[105][105];int k, n;int dfs(int

2015-08-15 21:50:30 162

原创 EOJ 2521 Guarding the Farm

题目大意:统计图中具有相同元素的连通块个数,需保证该连通块周围的所有元素都比连通块元素小。思路:DFS入门题#include #include using namespace std;int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1};int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};int n, m, flag;in

2015-08-15 21:44:46 297

原创 eoj 1848 你是ACM吗?

有N个点,求点1到其余N-1点的最小环路之和.无向图中的最小环可用floyd变式方法求得,有向图中的最小环可用两次dij求.#include #include #include #include #include using namespace std;/*  用到的还是最基本的dij方法,求点1到点2,3...n-1套用模版就行    在求点2,3...

2015-08-09 20:19:14 398

原创 hdu 2544 最短路

最短路的入门题朴素的dij写了一遍之后拿优先队列又写了一遍#include #include #include #include #include using namespace std;struct edge{ int to, dist; edge(int v, int d) : to(v), dist(d) {}};struct no

2015-08-09 19:51:42 154

原创 poj 2387 Til the Cows Come Home

最基本的最短路问题 #include #include #include #include using namespace std;const int INF = 0x3f3f3f3f;int edge[2005][2005];int main(){ int n, k; cin >> k >> n; int v, u, dis; for (int

2015-08-09 19:40:36 158

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除