
搜索-暴力搜索
文章平均质量分 62
JeraKrs
本人目前就职于百度商业研发部,有需要内推的朋友简历可发我邮箱 jerakrs@qq.com
展开
-
uva 216 Getting in Line(暴力枚举)
Getting in Line Computer networking requires that the computers in the network be linked.This problem considers a ``linear" network in which the computers are chained together原创 2013-07-20 01:32:11 · 1370 阅读 · 0 评论 -
uva 729 The Hamming Distance Problem
The Hamming Distance Problem The Hamming distance between two strings of bits (binary integers) is the number of corresponding bit positions that differ. This can be found by using XOR原创 2013-07-18 10:48:57 · 1267 阅读 · 0 评论 -
uva 11218 KTV(DFS)
KTVOne song is extremely popular recently, so you and your friends decided to sing it in KTV. The song has 3 characters, so exactly 3 people should sing together each time (yes, there are 3 mi原创 2013-08-01 21:20:26 · 1429 阅读 · 0 评论 -
uva 208 Firetruck (DFS + 并查集)
Firetruck The Center City fire department collaborates with the transportation department to maintain maps of the city which reflects the current status of the city streets. On any given原创 2013-08-04 14:09:20 · 1269 阅读 · 0 评论 -
uva 167 The Sultan's Successors(回溯)
The Sultan's Successors The Sultan of Nubia has no children, so she has decided that the country will be split into up to k separate parts on her death and each part will be inherited原创 2013-07-31 09:52:34 · 2208 阅读 · 0 评论 -
uva 10344 23 out of 5(DFS)
23 Out of 5Input: standard inputOutput: standard outputTime Limit: 1 secondMemory Limit: 32 MBYour task is to write a program that can decide whether you can find an arithmetic expression co原创 2013-07-20 13:16:04 · 1279 阅读 · 0 评论 -
uva 146 ID Codes
ID Codes It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby to counter a chronic brea原创 2013-07-18 10:39:16 · 1152 阅读 · 0 评论 -
uva 331 Mapping the Swaps(DFS+回溯)
Mapping the Swaps Sorting an array can be done by swapping certain pairs of adjacent entries in the array. This is the fundamental technique used in the well-known bubble sort. If we l原创 2013-07-20 14:57:15 · 1036 阅读 · 0 评论 -
uva 539 The Settlers of Catan
The Settlers of Catan Within Settlers of Catan, the 1995 German game of the year, players attempt to dominate an island by building roads, settlements and cities across its uncharted w原创 2013-07-16 14:06:09 · 1453 阅读 · 1 评论 -
uva 11205 The Broken Pedometer
The Broken Pedometer The ProblemA marathon runner uses a pedometer with which he is having problems. In the pedometer the symbols are represented by seven segments (or LEDs):But原创 2013-07-17 13:05:45 · 1239 阅读 · 0 评论 -
uva 193 Graph Coloring(DFS)
Graph Coloring You are to write a program that tries to find an optimal coloring for a given graph. Colors are applied to the nodes of the graph and the only available colors are black原创 2013-08-04 13:42:04 · 1458 阅读 · 0 评论 -
uva 10050 Hartals(枚举)
Problem D: Hartals A social research organization has determined a simple set of parameters to simulate the behavior of the political parties of our country. One of the parameters is a p原创 2013-07-19 20:30:02 · 1158 阅读 · 0 评论 -
uva 10167 Birthday Cake
Problem G. Birthday Cake BackgroundLucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them.Now we put the cake onto a Descartes coordinate. Its center原创 2013-07-17 12:57:03 · 1316 阅读 · 0 评论 -
uva 10098 Generating Fast, Sorted Permutation
Generating Fast, Sorted PermutationInput: Standard InputOutput: Standard Output Generating permutation has always been an important problem in computer science. In this problem you will have原创 2013-07-18 10:44:20 · 1364 阅读 · 0 评论 -
uva 10001 Garden of Eden (DFS)
Garden of Eden Cellular automata are mathematical idealizations of physical systems in which both space and time are discrete, and the physical quantities take on a finite set of discret原创 2013-08-05 00:02:02 · 1257 阅读 · 2 评论 -
uva 10160 Servicing Stations(DFS+剪枝)
Servicing stationsA company offers personal computers for sale in N towns (3 <= N <= 35). The towns are denoted by 1, 2, ..., N. There are direct routes connecting M pairs from among these tow原创 2013-08-05 21:10:17 · 2066 阅读 · 0 评论 -
uva 592 Island of Logic (搜索)
Island of Logic The Island of Logic has three kinds of inhabitants: divine beings that always tell the truth, evil beings that always lie, and human beings that are truthful during the原创 2013-08-05 00:33:41 · 1860 阅读 · 0 评论 -
uva 11520 Fill the Square(DFS)
Fill the SquareInput: Standard InputOutput: Standard Output In this problem, you have to draw a square using uppercase English Alphabets.To be more precise, you will be given a square grid w原创 2013-08-01 00:07:26 · 915 阅读 · 0 评论 -
hdu 1016 Prime Ring Problem(DFS)
DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Not原创 2013-08-01 00:03:11 · 1047 阅读 · 0 评论 -
uva 185 Roman Numerals (深搜+字符串处理)
Roman Numerals The original system of writing numbers used by the early Romans was simple but cumbersome. Various letters were used to represent important numbers, and these were then原创 2013-08-08 08:51:40 · 1509 阅读 · 0 评论 -
uva 131 The Psychic Poker Player(直接枚举)
The Psychic Poker Player In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards an原创 2013-08-11 21:28:51 · 1736 阅读 · 0 评论 -
uva 197 Cube(空间几何+回溯)
Cube There was once a 3 by 3 by 3 cube built of 27 smaller cubes. It has fallen apart into seven pieces:Figure 1: The seven pieces that once formed a cube原创 2013-08-11 10:00:45 · 1891 阅读 · 0 评论 -
uva 301 Transportation (DFS)
Transportation Ruratania is just entering capitalism and is establishing new enterprising activities in many fields including transport. The transportation company TransRuratania is st原创 2013-08-11 14:08:48 · 1128 阅读 · 0 评论 -
uva 565 Pizza Anyone?(二进制+搜索)
Pizza Anyone? You are responsible for ordering a large pizza for you and your friends. Each of them has told you what he wants on a pizza and what he does not; of course they all under原创 2013-08-06 19:47:52 · 1391 阅读 · 0 评论 -
uva 270 Lining Up(暴力+ 几何)
题目连接:270 - Lining Up题目大意:给出一系列点,要求找出共线的点数最大的值。解题思路:暴力,遍历每两个点确定的直线上又多少点, 每次更新最大值。三个点共线的性质:A(X1,Y1),B(X2,Y2),C(X3,Y3);这个时候有(Y2-Y1)/(X2-X1) = (Y3-Y2)/(X3-X2)最好转化成(Y2 - Y1) * (X3 - X2) =原创 2013-08-24 13:55:18 · 1489 阅读 · 0 评论 -
uva 10422 Knights in FEN(迭代dfs)
Knights in FENInput: standard inputOutput: standard outputTime Limit: 10 seconds There are black and white knights on a 5 by 5 chessboard. There are twelve of each color, and there is one原创 2013-08-12 21:51:58 · 1158 阅读 · 0 评论 -
uva 10591 Happy Number(判重)
Description Problem CHappy NumberTime Limit1 Second Let the sum of the square of the digits of a positive integer S0 be represented by S1. In a simila原创 2013-08-15 22:53:52 · 1294 阅读 · 0 评论 -
uva 141 The Spot Game(STL set)
The Spot Game The game of Spot is played on an NxN board as shown below for N = 4. During the game, alternate players may either place a black counter (spot) in an empty square or remove o原创 2013-08-17 15:41:02 · 1403 阅读 · 0 评论 -
uva 188 Perfect Hash(进制转换 + 遍历)
Perfect Hash Perfect Software, Inc. has obtained a government contract to examine text flowing through a high-speed network for the occurrence of certain words. Your boss, Wally Perfect, h原创 2013-08-17 11:26:33 · 1782 阅读 · 0 评论 -
uva 704 Colour Hash(隐式图搜索+ 模拟)
Colour Hash This puzzle consists of two wheels. Both wheels can rotate both clock and counter-clockwise. They contain 21 coloured pieces, 10 of which are rounded triangles and 11 of wh原创 2013-08-17 11:41:09 · 1448 阅读 · 0 评论 -
hdu 4707 Pet(图 + 邻接表)
题目连接:4707 - Pet题目大意:给出n和deep, 然后给出n - 1个关系(关系图为有向无环图,0~n - 1), 然后找出和0的关系大于deep的点有多少个。解题思路:用邻接表(借助vector)保存关系, dfs搜索, 当d >= 2时返回, 然后遍历一遍所有点, 统计没有搜索过的点。#include #include #include us原创 2013-09-08 20:44:04 · 1043 阅读 · 0 评论 -
uva 317 - Hexagon(规律推导)
题目连接:317 - Hexagon题目大意:在一个19个六边形组成的图形上玩一个游戏,给出9个数字, 分成3组, 分别可以填在左上角, 上, 有上角,因为对于小六边形来说, 对边的数是相同的, 然后这样9个数可以组成27个不同的小六边形, 现在要将在这27个小的六边形中选取19个填入图形中, 尽量使得的分最高,并且不可以重复使用小六边形。 得分的计算是对应图形的某一方向上, 如果原创 2013-09-02 23:59:12 · 1729 阅读 · 0 评论 -
poj 1573 - Robot Motion(BFS递推)
题目链接:POJ 1573- Robot Motion题目大意:给出一张图,图上标明了可行走的方向一个机器人从指定的位置进入,问能否离开这张图(任意方向)解题思路:bfs因为只有一个方向,即移动方向已经确定,所以不需要递归,代码量也很少,所以建议尝试递推。#include #include const int N = 105;const int dir原创 2013-10-18 14:24:53 · 983 阅读 · 0 评论 -
uva 10308 - Roads in the North(dfs)
题目链接:uva 10308 - Roads in the North题目大意:给出一个无环无向图,求任意两点间的最大距离。输入空行问该组测试输入结束。解题思路:输入比较恶心,因为这个WA了一次,这题可以用dfs去做,任意选一个节点作为根节点,然后遍历与它相连的所有点,维护最大值就可以了,因为任意两点可以看成是以父亲节点而相连的。#include #inc原创 2013-11-04 20:50:13 · 1685 阅读 · 0 评论 -
uva 11045 - My T-shirt suits me(dfs)
题目链接:11045 - My T-shirt suits me题目大意:给出n和m,表示有n件衣服,然后有m个人,每个人可以穿两种型号的衣服,总共有六种型号的衣服,各n / 6件, 问说是否可以让每个人都有可以穿的衣服。解题思路:这题貌似是二分图匹配,但因为m不大,所以直接暴力做了,枚举人,两种选择。#include #include const int原创 2013-11-22 14:19:11 · 1806 阅读 · 0 评论 -
uva 639 Don't Get Rooked(回溯)
Don't Get Rooked In chess, the rook is a piece that can move any number of squares vertically or horizontally. In this problem we will consider small chess boards (at most 44) that c原创 2013-07-20 13:10:05 · 1304 阅读 · 0 评论 -
uva 1267 - Network(dfs)
题目链接:uva 1267 - Network题目大意:给出n,s,k,即有n台客户端和服务器(边界为客户端),然后给出n-1条边,连接n台终端,现在在序号为s的服务器上有一个资源,为了方便所有用户浏览(访问路径长度不超过k),要在较少的服务器上复制资源,问说最少再在几个服务器上复制资源。解题思路:首先现将无根图转化成树,以资源所在的服务器s为根,然后dfs建树,建树的过程原创 2013-12-07 21:13:50 · 1311 阅读 · 0 评论 -
uva 11520 - Fill the Square(贪心+枚举)
题目链接:uva 11520 - Fill the Square题目大意:给出一张图,'.'的地方要用大写字母去填,要求说每个位置的上下左右如果存在的话所填的字母不能和当前位置相同。输出从上到下,从左到右字典序最小的方案。解题思路:从上到下,从左到右开始枚举,每次碰到'.'就从‘A’开始检测直到可以填入为止。#include #include const原创 2013-12-07 19:03:42 · 1252 阅读 · 0 评论 -
uva 1030 - Image Is Everything(迭代更新)
题目链接:uva 1030 - Image Is Everything题目大意:有一个最大为n*n*n的立方体的一个不规整立体,由若干个1*1*1的小正方体构成(每一个小正方体被涂成不同的颜色),给出n,然后是该立体的前、左、后、右、上和下的视图,然后判断该立体的最大体积是多少。解题思路:首先先把所有视图上为‘.'的地方清空,然后枚举视图上不为’.'的地方,计算对应的坐标第原创 2013-12-02 21:15:04 · 1944 阅读 · 0 评论 -
uva 11464 - Even Parity(暴力枚举)
题目链接:uva 11464 - Even Parity题目大意:给出一个由0和1组成的矩阵,修改最少的0变成1,使得矩阵中每个位置的上下左右存在的情况下,和为偶数,无解输出-1。解题思路:枚举,但是枚举所有位置的话,n最大为15,有2^255,肯定超时。但是不难发现,如果确定了i行,那么i + 1行肯定是确定。所以只要枚举第一行就可以了。#include #原创 2013-12-03 20:20:42 · 1690 阅读 · 0 评论