hdu 汉诺塔VII
摘要:View Code #include<iostream>using namespace std;bool flag;void DFS(int n,int *A,int *B,int *C){ if(n==0) { flag = true; return ; } if(B[0]&&n==B[1])//n号不会出现在B柱 { flag = false; return ; } if(A[0]&&n==A[1])//n号在A柱上 { A[1]=A[0]-1; DFS(n-...
阅读全文
hdu 4337 King Arthur's Knights【dfs 深度搜索】
摘要:View Code #include <iostream>#include <cstdio>#include <cmath>#include <cstring>#define maxn 155using namespace std;int map[maxn][maxn],res[maxn];bool vt[maxn];int n,m;bool flag;void dfs(int pos,int num){ int i; if (flag) return ; res[num] = pos; for (i = 1;i <= n;++i) { i
阅读全文
POJ 3561 Pseudographical recognizer(搜索)
摘要:View Code #include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>using namespace std;#define MAX_LEN 101#define is_valid(x, y) ((x)>=0 && (x)<N && (y)>=0 && (y)<M)int N, M;char image[MAX_LEN][MAX_LEN];int visited[MAX_LEN][MA
阅读全文
hdu4324 Triangle Love【拓扑排序】有向无环图
摘要:View Code /*5001001000001001111011100050111100000010000110001110*/#include<iostream>#include<cstdio>using namespace std;#define N 2010int indegree[N],a[N][N];char b[N];int main(){// freopen("in.txt","r",stdin); int n,t,x,p=1; scanf("%d",&t); while(t--){
阅读全文
Power transmission【有向图】
摘要:View Code #include<iostream>#include<iomanip>#include<cstdio>#include<queue>using namespace std;struct node{ int dest; double value; node* next; node() { next=NULL; }}edge[50010];//构造点int n,s,t;double power;double len[50010];node temp[2500010];queue<int> ans;void bfs(){
阅读全文
pku 3414 Pots 【BFS广度搜索】
摘要:View Code /* pku 3414 Pots BFS+记录路径2011-04-15 18:00题目意思.1. 给出两个容积分别为 A 、B 的空瓶子,求经过下列操作是否能得到某个瓶子 装 体积为 C 的水。2. 1> 把某个瓶子装满,2> 把某个瓶子的水倒光,3> 把某个瓶子的水倒入另一个。思路: 由于 某个状态最多可以推出 六个状态。 1> 当 A 瓶未满时,把 A 瓶装满 2> 当 B 瓶未满时,把 B 瓶装满 3> 当 A 瓶非空时,把 A 瓶倒光 4> 当 B 瓶非空时,把 B 瓶倒光 ...
阅读全文