ACM_搜索
zz你的名字
不奢望过多,只希望未来的自己没有过多的遗憾。
展开
-
NYOJ 最小步数(简单深搜与广搜)
题目http://115.159.40.116/problem_show.php?pid=4670 二维地图最短路问题 广搜,这个题深搜也可以,先写个广搜吧#include<iostream>#include<string.h>#include<queue>#include<algorithm>using namespace std;int si,sj,di,dj;int map[9原创 2016-12-27 19:24:54 · 752 阅读 · 0 评论 -
fzu Problem 2150 Fire Game
Problem 2150 Fire Game 题意:找两个起火点,把草烧完,求最短时间,如果烧不完,输出-1 思路:先找到草堆数目,然后暴力枚举任意两个点。水题,还以为会超时呢#include<stdio.h>#include<string.h>#include<queue>#include<iostream>#include&l...原创 2018-04-20 10:29:24 · 128 阅读 · 0 评论 -
UVA - 167
UVA - 167 八皇后问题,用c[i]=k表示第i行放置第k列。#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;const int maxn=25;int mapp[maxn][maxn];...原创 2018-04-14 09:15:57 · 216 阅读 · 0 评论 -
poj3026Borg Maze
题目 题意:在一个y行 x列的迷宫中,有可行走的通路空格’ ‘,不可行走的墙’#’,还有两种英文字母A和S,现在从S出发,要求用最短的路径L连接所有字母,输出这条路径L的总长度。 做法:BFS+最小生成树 我的做法是先把图转换成一个由-1表示墙,0表示空格,>=1的数字表示点A和S构成的图,然后bfs求出任意两点间的距离,最后用prime算法求出答案即可。 坑点是数据的任意一行的最后...原创 2018-04-02 16:01:56 · 185 阅读 · 1 评论 -
poj1664(dfs
poj1664 感觉dfs+接口问题一样,不过就是要搞清有几个接口。 1.m==1||n==1时,只有一种放的方式。 2.m3.m>n时,先每个盘子放一个苹果,然后考虑剩下的苹果放n个盘子的情况。还有m个苹果放n-1个盘子里的情况,所以返回dfs(m-n,m)+dfs(m,n-1). 但是m-n有可能等于0,所以第一种情况添加m==0的情况,虽然不添加也对,可能是数据水。#inc原创 2018-02-02 15:43:59 · 216 阅读 · 0 评论 -
poj3087 Shuffle'm Up
A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Eac原创 2017-05-22 14:16:59 · 641 阅读 · 1 评论 -
hdu1241 Oil Deposits (bfs水题)
Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a原创 2017-05-27 20:17:12 · 1032 阅读 · 0 评论 -
poj3984 迷宫问题(简单搜索+记录路径)
定义一个二维数组: int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 Input 一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解原创 2017-05-23 21:48:30 · 348 阅读 · 0 评论 -
poj3126 Prime Path(bfs+40入口+素数判定)
The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It is a matter of se原创 2017-05-24 21:09:11 · 439 阅读 · 0 评论 -
poj1426 Find The Multiple(dfs双入接口+模运算)
DescriptionGiven a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200原创 2017-05-24 19:09:16 · 296 阅读 · 0 评论 -
poj3278 Catch That Cow
Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 89585 Accepted: 28099 DescriptionFarmer John has been informed of the location of a fugitive cow and wants to ca原创 2017-05-05 14:12:14 · 278 阅读 · 0 评论 -
poj2251 Dungeon Master
Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 33157 Accepted: 12711 DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dung原创 2017-04-29 20:06:48 · 534 阅读 · 0 评论 -
poj1321 棋盘问题
棋盘问题 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42124 Accepted: 20520 Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的原创 2017-03-13 16:51:38 · 419 阅读 · 0 评论 -
UVA11624 Fire!
Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of the maze neglected to create a fire escape plan. Help Joe escape the maze. Given Joe’s location in the原创 2017-01-09 21:28:39 · 452 阅读 · 0 评论 -
Find a way 两路广搜
Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki. Yifenfei’s home is at the co原创 2016-12-28 19:00:24 · 721 阅读 · 0 评论 -
HDU Dungeon Master广搜
题目https://vjudge.net/contest/145660?#problem/B 三维空间最短路问题用广搜#include<iostream>#include<string.h>#include<queue>//队列头文件using namespace std;char map[35][35][35];//地图int a,b,c;int vis[35][35][35];//原创 2016-12-27 18:42:12 · 447 阅读 · 0 评论 -
hdu 6341 Problem J. Let Sudoku Rotate
直接暴力搜+可行性剪枝。具体看代码,注意:顺时针旋转#include<bits/stdc++.h>using namespace std;int vis[20];char s[20][20];int a[20][20],b[20][20];int ans;void ro(int x,int y){ for(int i=x;i<x+4;i++) ...原创 2018-08-02 15:10:32 · 177 阅读 · 0 评论