
DFS/BFS
YRZ-James
who say you are not perfect?
展开
-
UVA-439(Knight Moves)
UVA-439(Knight Moves)题目:https://cn.vjudge.net/problem/UVA-439代码如下:#include<bits/stdc++.h>using namespace std;#define MAX 11string s1,s2;int a1,a2,b1,b2;int direction [8][2] = {{2,1},{1...原创 2018-11-18 17:12:19 · 226 阅读 · 0 评论 -
S - 鸣人和佐助
S - 鸣人和佐助题目:佐助被大蛇丸诱骗走了,鸣人在多少时间内能追上他呢?已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置。地图上的每个位置都可以走到,只不过有些位置上有大蛇丸的手下,需要先打败大蛇丸的手下才能到这些位置。鸣人有一定数量的查克拉,每一个单位的查克拉可以打败一个大蛇丸的手下。假设鸣人可以往上下左右四个方向移动,每移动一个距离需要花费1个单位时间,打败大蛇丸的手下不需要时...原创 2018-11-28 19:39:34 · 359 阅读 · 0 评论 -
I - Fire!
I - Fire!题目:https://cn.vjudge.net/contest/271046#problem/I代码如下:#include<iostream>#include<string>#include<queue>#include<cstdio>using namespace std;#define MAX 1005#d...原创 2018-12-04 20:12:51 · 211 阅读 · 0 评论 -
F - Prime Path
F - Prime Path题目: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...原创 2018-11-25 19:59:34 · 129 阅读 · 0 评论 -
E - Find The Multiple
E - Find The Multiple题目:Given 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 ...原创 2018-11-25 16:32:07 · 102 阅读 · 0 评论 -
B - Dungeon Master
B - Dungeon Master题目:You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to mov...原创 2018-11-24 14:29:34 · 141 阅读 · 0 评论 -
UVA-572(Oil Deposits)
UVA-572(Oil Deposits)题目:https://cn.vjudge.net/problem/UVA-572代码如下:#include&lt;bits/stdc++.h&gt;using namespace std;char str[105][105];bool vis[105][105];int m,n,direction[8][2] = {{-1,0},{-1,...原创 2018-11-18 13:26:21 · 220 阅读 · 0 评论 -
抓住那头牛(POJ3278)
抓住那头牛(POJ3278)题目:https://cn.vjudge.net/problem/POJ-3278代码如下://#include<bits/stdc++.h>#include<iostream>#include<cstdio>#include<queue>#include<cstring>using name...原创 2018-11-18 15:23:35 · 554 阅读 · 0 评论 -
P - ROADS
P - ROADS题目:N cities named with numbers 1 … N are connected with one-way roads. Each road has two parameters associated with it : the road length and the toll that needs to be paid for the road (exp...原创 2018-11-22 19:29:47 · 125 阅读 · 0 评论 -
N - 城堡问题
N - 城堡问题题目:https://cn.vjudge.net/contest/271046#problem/N代码如下:#include<bits/stdc++.h>using namespace std;#define MAX 55int a[MAX][MAX],vis[MAX][MAX],sum = 0,max_size = 0;void dfs(int i...原创 2018-11-21 19:27:03 · 628 阅读 · 0 评论 -
O - 踩方格
O - 踩方格题目:有一个方格矩阵,矩阵边界在无穷远处。我们做如下假设:a. 每走一步时,只能从当前方格移动一格,走到某个相邻的方格上;b. 走过的格子立即塌陷无法再走第二次;c. 只能向北、东、西三个方向走;请问:如果允许在方格矩阵上走n步,共有多少种不同的方案。2种走法只要有一步不一样,即被认为是不同的方案。Input允许在方格上行走的步数n(n <= ...原创 2018-11-21 17:36:00 · 535 阅读 · 1 评论 -
J - 迷宫问题
J - 迷宫问题题目:定义一个二维数组: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 ×...原创 2018-11-21 17:24:33 · 734 阅读 · 0 评论 -
POJ-1321 棋盘问题
POJ-1321 棋盘问题题目:在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <...原创 2018-11-18 21:17:35 · 145 阅读 · 0 评论 -
H - Pots
题目:You are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;DROP(i) empty the ...原创 2019-01-21 14:11:22 · 171 阅读 · 0 评论