
搜索与回溯
文章平均质量分 55
我要满满的AC
不积跬步,无以至千里
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ3620 Avoid The Lakes
#include #include int ans[10000]; int c[100][100],vis[100][100],n,m,t; int dx[4]={1,0,0,-1}; int dy[4]={0,1,-1,0}; bool pan(int h,int l) { if(c[h][l]&&!vis[h][l]){vis[h][l]=1;return true;}原创 2014-07-17 19:18:09 · 384 阅读 · 0 评论 -
hdu 5487 Difference of Languages BFS
题意:给你两个DFA,每个状态在另一个字母的作用下变成另一个状态。其字典序最小的一个字符串,使得其中一个变成可接受的状态,另一个不是。 方法:bfs枚举最后的状态,并记录第一个状态。#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<queue> #pragma comment(l原创 2015-10-07 15:22:48 · 334 阅读 · 0 评论 -
HDU5012 Dice dfs
#include #include #include using namespace std; int a[4][2],b[4][2]; int vis[700000]; int ans; int zhong; void d1(){ int x=a[2][0]; a[2][0]=a[1][0];a[1][0]=a[2][1]; a[2][1]=a[1][1];a[1][1]=x;原创 2014-09-14 21:11:00 · 357 阅读 · 0 评论 -
zoj1424 Painting A Board
#include #include struct node { int x1,x2,y1,y2,code; }rec[15]; int map[15][15],ru[15],vis[15],n,minn; bool pan(int i,int j) { if(rec[i].y2==rec[j].y1&&!(rec[i].x2rec[j].x2)) return true; else re原创 2014-07-25 22:39:34 · 310 阅读 · 0 评论 -
poj3278 Catch That Cow
做得有点蛋疼的题目,jianzhi原创 2014-07-18 16:06:40 · 359 阅读 · 0 评论 -
POJ2362 Square
这题跟POJ1011题很像,但感觉比这题简单些。 #include #include #include int a[65],v[65]; int cmp(const void *a,const void *b) { return *(int *)b-*(int*)a; } bool dfs(int m,int cur,int amount,int x0,int t) { if(am原创 2014-07-18 21:24:14 · 366 阅读 · 0 评论 -
POJ1011 Sticks
这题剪枝实在是很关键! #include #include #include int a[65],v[65]; int cmp(const void *a,const void *b) { return *(int *)b-*(int*)a; } bool dfs(int m,int cur,int amount,int x0,int t) { if(amount==m)retur原创 2014-07-18 21:23:53 · 424 阅读 · 0 评论 -
poj2488 A Knight's Journey
这题也没什么新意,纯粹深搜就行了。原创 2014-07-17 21:46:10 · 386 阅读 · 0 评论 -
poj2243 跳马问题,bfs一下就可以了。
#include #include #include using namespace std; char a[3],b[3]; int vis[8][8],m; int dx[8]={1,2,2,1,-1,-2,-2,-1}; int dy[8]={2,1,-1,-2,-2,-1,1,2}; struct node { int x,y; }p1,p2,d[8]原创 2014-07-17 19:12:47 · 631 阅读 · 0 评论 -
HDU 5113 Black And White dfs+剪枝
题意:给你一个n*m的矩阵,现有K种颜料,要涂满整个矩阵。每种颜料可以涂的矩阵个数为c[i],涂矩阵时要求相邻矩阵颜色不同。现求一种合法的涂法。 方法:dfs+剪枝 剪枝技巧,对未填方块进行黑白染色,则需当前颜料的个数大于(left+1)/2个,才能使满足要求。 #include #include #include #include #include #include using names原创 2015-10-23 14:33:47 · 462 阅读 · 0 评论