
搜索大法
so_so_y
start to record bugs <- so hard so brave
展开
-
团体程序设计天梯赛 喊山(BFS)
题意 喊山,是人双手围在嘴边成喇叭状,对着远方高山发出“喂—喂喂—喂喂喂……”的呼唤。呼唤声通过空气的传递,回荡于深谷之间,传送到人们耳中,发出约定俗成的“讯号”,达到声讯传递交流的目的。原来它是彝族先民用来求援呼救的“讯号”,慢慢地人们在生活实践中发现了它的实用价值,便把它作为一种交流工具世代传袭使用。 一个山头呼喊的声音可以被临近的山头同时听到。题目假设每个山头最多有两个能听到它的临近山头。原创 2017-03-27 20:37:25 · 508 阅读 · 0 评论 -
51nod 1109 01组成的N的倍数(宽搜+剪枝)
Description给定一个自然数N,找出一个M,使得M > 0且M是N的倍数,并且M的10进制表示只包含0或1。求最小的M。 例如:N = 4,M = 100。Input输入1个数N。(1 <= N <= 10^6)Output输出符合条件的最小的M。Input示例4Output示例100解题思路主要是一个很重要的剪枝——余数的标记,当一个余数已经出现过一次后,在放到队列里进行搜索时多余的运算原创 2017-10-14 20:27:50 · 342 阅读 · 0 评论 -
51nod 1444 破坏道路 最短路
Description在某一个国家,那儿有n个城市,他们通过m条双向道路相连。城市从1到n编号。如果城市a和b通过一条道路直接相连,那么他们之间的距离就是一个小时。这个国家的道路网络可以允许你从任意一个城市到达另外的城市。 现在你要破坏尽可能多的道路,但是要保证从城市s1到t1不超过l1小时,并且从城市s2到t2不超过l2小时。 输出最多可以破坏的道路数目,如果没有解,请输出-1Input单组测原创 2017-10-23 22:14:49 · 289 阅读 · 0 评论 -
Codeforces Round #449 div2 C(递归求解)
DescriptionWhat are you doing at the end of the world? Are you busy? Will you save us? Nephren is playing a game with little leprechauns.She gives them an infinite array of strings, f0… ∞.f0 is “What原创 2017-12-03 21:46:36 · 414 阅读 · 0 评论 -
Codeforces Good Bye 2016 D. New Year and Fireworks(bfs/dfs)
DescriptionOne tradition of welcoming the New Year is launching fireworks into the sky. Usually a launched firework flies vertically upward for some period of time, then explodes, splitting into severa原创 2017-11-24 14:49:48 · 247 阅读 · 0 评论 -
Codeforces Round #459 (Div. 2) D.MADMAX(记忆化搜索)
DescriptionAs we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she’s not the best at games. ...原创 2018-02-15 15:00:32 · 218 阅读 · 0 评论 -
Codeforces Round #460(Div. 2) D. Substring(记忆化搜索+判环)
DescriptionYou are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path’s value as the number of the most frequently occurring letter. For...原创 2018-02-15 15:25:57 · 276 阅读 · 0 评论 -
牛客网 石油采集(二分图最大匹配,dfs)
链接:https://www.nowcoder.com/acm/contest/76/A 来源:牛客网题目描述 随着海上运输石油泄漏的问题,一个新的有利可图的行业正在诞生,那就是撇油行业。如今,在墨西哥湾漂浮的大量石油,吸引了许多商人的目光。这些商人们有一种特殊的飞机,可以一瓢略过整个海面20米乘10米这么大的长方形。(上下相邻或者左右相邻的格子,不能斜着来)当然,这要求一瓢撇过去的...原创 2018-02-16 15:39:14 · 458 阅读 · 0 评论 -
51nod 1489 蜥蜴和地下室(dfs)
Description哈利喜欢玩角色扮演的电脑游戏《蜥蜴和地下室》。此时,他正在扮演一个魔术师。在最后一关,他必须和一排的弓箭手战斗。他唯一能消灭他们的办法是一个火球咒语。如果哈利用他的火球咒语攻击第i个弓箭手(他们从左到右标记),这个弓箭手会失去a点生命值。同时,这个咒语使与第i个弓箭手左右相邻的弓箭手(如果存在)分别失去b(1 ≤ b < a ≤ 10)点生命值。 因为两个端点的弓...原创 2018-02-16 21:24:06 · 333 阅读 · 0 评论 -
codeforces 618 D. Hamiltonian Spanning Tree(dfs)
DescriptionA group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are roads in total. It takes exactly y seconds to traverse any s...原创 2018-02-26 00:53:14 · 317 阅读 · 0 评论 -
历届试题 九宫重排 (bfs+康托展开(哈希))
问题描述 如下面第一个图的九宫格中,放着 1~8 的数字卡片,还有一个格子空着。与空格子相邻的格子中的卡片可以移动到空格中。经过若干次移动,可以形成第二个图所示的局面。 我们把第一个图的局面记为:12345678. 把第二个图的局面记为:123.46758 显然是按从上到下,从左到右的顺序记录数字,空格记为句点。 本题目的任务是已知九宫的初态和终态,求最少经过多少步的...原创 2018-03-30 11:38:48 · 293 阅读 · 0 评论 -
POJ 3411 Paid Roads(dfs技巧)
DescriptionA network of m roads connects N cities (numbered from 1 to N). There may be more than one road connecting one city with another. Some of the roads are paid. There are two ways to pay for tra原创 2017-10-05 10:02:46 · 383 阅读 · 0 评论 -
POJ 3321 Apple Tree(树状数组+DFS构建)
DescriptionThere is an apple tree outside of kaka’s house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.The tre原创 2017-08-11 15:39:43 · 481 阅读 · 0 评论 -
团体程序设计天梯赛 红色警报(DFS)
题意 战争中保持各个城市间的连通性非常重要。本题要求你编写一个报警程序,当失去一个城市导致国家被分裂为多个无法连通的区域时,就发出红色警报。注意:若该国本来就不完全连通,是分裂的k个区域,而失去一个城市并不改变其他城市之间的连通性,则不要发出警报。输入格式:输入在第一行给出两个整数N(0 < N <=500)和M(<=5000),分别为城市个数(于是默认城市从0到N-1编号)和连接两城市的通路条数原创 2017-03-27 20:51:10 · 556 阅读 · 0 评论 -
HDU 2553 N皇后问题 && POJ 1321 棋盘问题 (深搜)
HDU 2553 N皇后问题Problem Description 在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。Input 共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output 共有若干行,每行一个正整数,原创 2017-03-15 11:37:11 · 540 阅读 · 0 评论 -
POJ 3009 Curling 2.0(深搜)
DescriptionOn Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square me原创 2017-03-15 11:11:44 · 399 阅读 · 0 评论 -
POJ 2251 Dungeon Master(广搜)
DescriptionYou 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 move one unit no原创 2017-03-15 10:48:03 · 320 阅读 · 0 评论 -
第七届蓝桥杯国赛 凑平方数
题意把0~9这10个数字,分成多个组,每个组恰好是一个平方数,这是能够办到的。比如:0, 36, 5948721再比如:10985247361, 25, 63907840, 4, 289, 15376等等...注意,0可以作为独立的数字,但不能作为多位数字的开始。分组时,必须用完所有的数字,不能重复,不能遗漏。如果不计较小组内数据的先后顺序,请问有多少种不同的分组方案?注意:需要提交的是原创 2017-05-22 18:19:26 · 703 阅读 · 0 评论 -
第七届蓝桥杯国赛 机器人塔
题意X星球的机器人表演拉拉队有两种服装,A和B。他们这次表演的是搭机器人塔。类似: A B B A B A A A B B B B B A BA B A B B A队内的组塔规则是: A 只能站在 AA 或 BB 的肩上。 B 只能站在 AB 或 BA 的肩上。你的任务是帮助拉拉队计算一下,在给定A与B的人数时,可以组成多少种花样的塔。输入一行两个整数 M 和原创 2017-05-23 18:57:56 · 1817 阅读 · 0 评论 -
第七届蓝桥杯国赛 一步之遥
题意从昏迷中醒来,小明发现自己被关在X星球的废矿车里。矿车停在平直的废弃的轨道上。他的面前是两个按钮,分别写着“F”和“B”。小明突然记起来,这两个按钮可以控制矿车在轨道上前进和后退。按F,会前进97米。按B会后退127米。透过昏暗的灯光,小明看到自己前方1米远正好有个监控探头。他必须设法使得矿车正好停在摄像头的下方,才有机会争取同伴的援助。或许,通过多次操作F和B可以办到。矿车上的动力原创 2017-05-23 09:33:01 · 2459 阅读 · 0 评论 -
POJ 1011 Sticks(深搜+剪枝)
DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks h原创 2017-04-23 17:57:31 · 469 阅读 · 0 评论 -
HDU 4101Ali and Baba (bfs)
DescriptionThere is a rectangle area (with N rows and M columns) in front of Ali and Baba, each grid might be one of the following: 1. Empty area, represented by an integer 0. 2. A Stone, represented原创 2017-07-15 00:11:06 · 304 阅读 · 0 评论 -
hihoCoder 156周 岛屿
描述给你一张某一海域卫星照片,你需要统计:1. 照片中海岛的数目2. 照片中面积不同的海岛数目3. 照片中形状不同的海岛数目其中海域的照片如下,"."表示海洋,"#"表示陆地。在"上下左右"四个方向上连在一起的一片陆地组成一座岛屿。.####.. .....#. ####.#. .....#. ..##.#. 上图所示的照片中一共有4座岛屿;其中3座面积为4,一座面积为2,所以不原创 2017-06-29 14:52:34 · 681 阅读 · 0 评论 -
Codeforces Detour(Dijkstra +爆搜)
DescriptionAfter last year’s edition of the BAPC, you are still stuck in Delft. In order to participate again this year, you are going to Amsterdam by bus. During the journey you look out of the win...原创 2018-05-02 21:26:16 · 488 阅读 · 0 评论