图论
sdfgdbvc
热闹是他们的,我什么也没有
展开
-
NYOJ 82 迷宫寻宝(一)
题目信息:迷宫寻宝(一)时间限制:1000 ms | 内存限制:65535 KB难度:4描述 一个叫ACM的寻宝者找到了一个藏宝图,它根据藏宝图找到了一个迷宫,这是一个很特别的迷宫,迷宫里有N个编过号的门(N 输入输入可能会有多组测试数据(不超过10组)。每组测试数据的第一行包含了两个整数M,N(1.表示可以走的路S:表示ACM的出发点G表示原创 2015-10-31 21:51:32 · 539 阅读 · 0 评论 -
Dijkstra算法之优先队列优化版本 By ACReaper Dijkstra
Dijksta算法中,如果我们采用的是邻接矩阵来存的,第一点浪费的空间比较多,第二点我们知道算法的时间复杂度在O(n*n),这样的算法可以说并不是很好,所以我们考虑优化它,那么可以从哪些地方优化呢,首先我们可以优化存储结构,采用邻接表来存储,其次我们可以用优先队列来排序大小,其时间复杂度大大降低。代码如下。需要注意的是pair是按照第一个元素的大小排序,如果相同才按照第二个,所以我们要把d[i转载 2016-04-18 16:04:45 · 218 阅读 · 0 评论 -
POJ 3723 Conscription
ConscriptionTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 10518 Accepted: 3715DescriptionWindy has a country, and he wants to build an army to pro原创 2016-04-17 09:29:22 · 158 阅读 · 0 评论 -
POJ 3268 Silver Cow Party
Silver Cow PartyTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 17213 Accepted: 7861DescriptionOne cow from each of N farms (1 ≤ N ≤ 1000) convenientl原创 2016-04-17 09:26:36 · 144 阅读 · 0 评论 -
POJ 2377 Bad Cowtractors
Bad CowtractorsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 12775 Accepted: 5304DescriptionBessie has been hired to build a cheap internet network am原创 2016-04-17 09:18:47 · 164 阅读 · 0 评论 -
POJ 2395 Out of Hay
Out of HayTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 14161 Accepted: 5500DescriptionThe cows have run out of hay, a horrible event that must be rem原创 2016-04-17 09:14:13 · 142 阅读 · 0 评论 -
HDU 2102 A计划
A计划Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15738 Accepted Submission(s): 3923Problem Description可怜的公主在一次次被魔王掳走一次次被骑士们救回来之原创 2016-04-17 09:11:53 · 155 阅读 · 0 评论 -
POJ 2488 A Knight's Journey
A Knight's JourneyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 38688 Accepted: 13121DescriptionBackgroundThe knight is getting bored of seeing the原创 2016-04-17 09:11:27 · 161 阅读 · 0 评论 -
POJ 3259 Wormholes
#include #include int N, M, W;struct node{ int u; int v; int w;} map[5500];int dist[505];bool Bellman_Ford(){ int i, j; for(i = 1; i < N; i++) for(j = 1; j <= 2*M+W; j++) if(dist[map原创 2016-04-17 09:10:38 · 153 阅读 · 0 评论 -
HDU 1317 XYZZY
XYZZYTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4153 Accepted Submission(s): 1151Problem DescriptionIt has recently been dis原创 2016-04-20 09:06:51 · 186 阅读 · 0 评论 -
POJ 1511 Invitation Cards
Invitation CardsTime Limit: 8000MS Memory Limit: 262144KTotal Submissions: 23934 Accepted: 7878DescriptionIn the age of television, not many people attend theater p原创 2016-04-20 09:12:15 · 312 阅读 · 0 评论 -
POJ 1077 Eight && HDU 1043 Eight 八数码问题(A*算法)
EightTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 32045 Accepted: 13910 Special JudgeDescriptionThe 15-puzzle has been around for over 100 years; e原创 2017-04-25 20:57:52 · 374 阅读 · 0 评论 -
HDU 2544 最短路-最短路总结
最短路Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 49834 Accepted Submission(s): 21933Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很原创 2016-04-15 20:59:21 · 260 阅读 · 0 评论 -
POJ 1094 Sorting It All Out
Sorting It All OutTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 31877 Accepted: 11086DescriptionAn ascending(上升的) sortedsequence(序列) ofdistinct(明显原创 2016-04-24 21:33:41 · 190 阅读 · 0 评论 -
拓扑排序的原理及其实现
原博客链接:http://blog.csdn.net/dm_vincent/article/details/7714519本文将从以下几个方面介绍拓扑排序: 拓扑排序的定义和前置条件 和离散数学中偏序/全序概念的联系 典型实现算法 Kahn算法 基于DFS的算法 解的唯一性问题 实际例子取材自以下材料:htt转载 2016-04-22 09:45:39 · 970 阅读 · 0 评论 -
POJ 3169 Layout
LayoutTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9520 Accepted: 4563DescriptionLike everyone else, cows like to stand close to their friends when q原创 2016-04-21 19:42:37 · 242 阅读 · 0 评论 -
HDU 1242 Rescue
RescueTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24500 Accepted Submission(s): 8643Problem DescriptionAngel was caught by th原创 2016-04-20 09:28:48 · 186 阅读 · 0 评论 -
POJ 3255 Roadblocks
RoadblocksTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 11445 Accepted: 4036DescriptionBessie has moved to a small farm and sometimes enjoys returni原创 2016-04-20 09:16:09 · 255 阅读 · 0 评论 -
POJ 1258 Agri-Net
Agri-NetTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 48946 Accepted: 20307DescriptionFarmer John has been elected mayor of his town! One of his campa原创 2016-04-16 21:40:34 · 156 阅读 · 0 评论 -
POJ 2139 Six Degrees of Cowvin Bacon
Six Degrees of Cowvin BaconTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 4239 Accepted: 2008DescriptionThe cows have been making movies lately, so the原创 2016-04-16 21:37:46 · 172 阅读 · 0 评论 -
NYOJ 1129 Salvation(技巧型深搜)
Salvation时间限制:1000 ms | 内存限制:65535 KB难度:3描述 神秘瀑布镇是一个神秘的地方,那里有吸血鬼,狼人,巫师,二重身。Klaus(吸血鬼祖先) 为了利用 Elena 的血液发展他的混血大军(吸血鬼&狼人),也来到了神秘瀑布镇。Stefan 因为深爱着 Elena ,于是 Stefan 决定去唤醒吸血鬼猎人,来解救原创 2016-04-15 20:45:49 · 342 阅读 · 0 评论 -
POJ-2386-Lake Counting
Lake CountingTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 27328 Accepted: 13730DescriptionDue to recent rains, water has pooled in various places in Fa原创 2016-04-15 20:40:16 · 146 阅读 · 0 评论 -
NYOJ-499-迷宫
迷宫时间限制:1000 ms | 内存限制:65535 KB难度:4描述 一个由 n * m 个格子组成的迷宫,起点是(1, 1), 终点是(n, m),每次可以向上下左右四个方向任意走一步,并且有些格子是不能走动,求从起点到终点经过每个格子至多一次的走法数。输入第一行一个整数 T 表示有 T 组测试数据。(T 对于每组测试数据:第一行两个整数 n, m,表示迷宫有原创 2016-04-15 20:38:24 · 339 阅读 · 0 评论 -
HDU-2181-哈密顿绕行世界问题
题目信息:哈密顿绕行世界问题Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2628 Accepted Submission(s): 1640Problem Description一个规则的实心十二面体原创 2016-04-15 20:33:10 · 184 阅读 · 0 评论 -
POJ-3278-Catch That Cow
题目信息:Catch That CowDescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN (0 ≤ N ≤ 100,000) on a number line a原创 2016-04-15 20:26:41 · 141 阅读 · 0 评论 -
搜索剪枝
搜索算法的通用优化方法[DFS][搜索剪枝]在很多情况下,我们已经找到了一组比较好的解。但是计算机仍然会义无返顾地去搜索比它更“劣”的其他解,搜索到后也只能回溯。为了避免出现这种情况,我们需要灵活地去定制回溯搜索的边界。*例题 计算机网络连接要将n(n台计算机连成网络,连接方法:去除首尾两台计算机与一台计算机相连以外,其他计算机只与两台计算机相连。连接的长度则为计算机连接的电缆的长转载 2016-04-26 10:11:02 · 286 阅读 · 0 评论 -
NYOJ 38 布线问题
题目信息:布线问题时间限制:1000 ms | 内存限制:65535 KB难度:4描述 南阳理工学院要进行用电线路改造,现在校长要求设计师设计出一种布线方式,该布线方式需要满足以下条件:1、把所有的楼都供上电。2、所用电线花费最少输入第一行是一个整数n表示有n组测试数据。(n每组测试数据的第一行是两个整数v,e.v表示学校里楼的总个数(v随后的e原创 2016-02-29 18:43:36 · 317 阅读 · 0 评论 -
NYOJ 722 数独
题目信息:数独时间限制:1000 ms | 内存限制:65535 KB难度:4描述 数独是一种运用纸、笔进行演算的逻辑游戏。玩家需要根据9×9盘面上的已知数字,推理出所有剩余空格的数字,并满足每一行、每一列、每一个3*3宫内的数字均含1-9,不重复。 每一道合格的数独谜题都有且仅有唯一答案,推理方法也以此为基础,任何无解或多解的题目都是不合格的。原创 2015-10-31 22:10:10 · 423 阅读 · 0 评论 -
POJ2251 - Dungeon Master
Dungeon MasterTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 24704 Accepted: 9565DescriptionYou are trapped in a 3D dungeon and need to find the quicke原创 2016-04-15 20:51:34 · 173 阅读 · 0 评论 -
POJ-1502 MPI Maelstrom
MPI MaelstromTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7769 Accepted: 4763DescriptionBIT has recently taken delivery of their new supercomputer, a 3原创 2016-04-15 20:54:16 · 202 阅读 · 0 评论 -
HDU 2066 一个人的旅行
一个人的旅行Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 29156 Accepted Submission(s): 10017Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居原创 2016-04-16 21:33:18 · 230 阅读 · 0 评论 -
POJ 1125 Stockbroker Grapevine
Stockbroker GrapevineTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 32943 Accepted: 18123DescriptionStockbrokers are known to overreact to rumours. You原创 2016-04-16 21:22:38 · 197 阅读 · 0 评论 -
NYOJ 115 城市平乱
城市平乱时间限制:1000 ms | 内存限制:65535 KB难度:4描述 南将军统领着N个部队,这N个部队分别驻扎在N个不同的城市。他在用这N个部队维护着M个城市的治安,这M个城市分别编号从1到M。现在,小工军师告诉南将军,第K号城市发生了暴乱,南将军从各个部队都派遣了一个分队沿最近路去往暴乱城市平乱。现在已知在任意两个城市之间的路行军所需的时间,你作为南将原创 2016-04-16 21:19:13 · 256 阅读 · 0 评论 -
POJ 2485 Highways
HighwaysTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 27341 Accepted: 12484DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately,原创 2016-04-15 21:30:04 · 527 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home
Til the Cows Come HomeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 40451 Accepted: 13760DescriptionBessie is out in the field and wants to get back to原创 2016-04-15 21:27:57 · 188 阅读 · 0 评论 -
NYOJ 1238 最小换乘
最少换乘时间限制:2000 ms | 内存限制:65535 KB难度:3描述 欧洲某城是一个著名的旅游胜地,每年都有成千上万的人前来观光旅行。Dr. Kong决定利用暑假好好游览一番。。年轻人旅游不怕辛苦,不怕劳累,只要费用低就行。但Dr. Kong年过半百,他希望乘坐BUS从住的宾馆到想去游览的景点,期间尽可量地少换乘车。 Dr. Kon买了一张旅游地图。他原创 2016-04-15 21:20:42 · 478 阅读 · 0 评论 -
蓝桥杯 幻方填空
幻方填空 幻方是把一些数字填写在方阵中,使得行、列、两条对角线的数字之和都相等。 欧洲最著名的幻方是德国数学家、画家迪勒创作的版画《忧郁》中给出的一个4阶幻方。 他把1,2,3,...16 这16个数字填写在4 x 4的方格中。 如图p1.jpg所示,即:16 ? ? 13? ? 11 ?9 ? ? *?原创 2016-04-15 21:02:15 · 1457 阅读 · 0 评论 -
POJ-1062 昂贵的聘礼
昂贵的聘礼Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 43614 Accepted: 12789Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。原创 2016-04-15 20:57:46 · 206 阅读 · 0 评论 -
双向BFS
转载自:http://blog.csdn.net/wdkirchhoff/article/details/41121517POJ 2243:题目大意:给定一个起点和一个终点,按骑士的走法(走日字),从起点到终点的最少移动多少次双向BFS双向bfs就是用两个队列,一个队列保存从起点开始的状态,另一个保存从终点开始向前搜索的状态,双向bfs主要是区分每个格子是从起点开始搜索到的转载 2017-04-25 21:09:47 · 327 阅读 · 0 评论