E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
Roads
POJ 1251 Jungle
Roads
题目连接: http://poj.org/problem?id=1251 题目大意: Lagrishan岛屿上的首领遇到一个问题。几年前外国援助的钱花在了修建两个村庄的道路上了,但是道路的毁坏是需要维修的,因此 村长必须放弃一些道路的维护。因此减少一些道路, 即使这些道路没有以前那么短了。长老们在讨论如何才能将所有的道路连通并且成本最低。你的任务就是编写一个程序来解决这个问题。 输入:
·
2015-11-11 08:19
poj
poj 1724
ROADS
1 1 2 http://poj.org/problem?id=1724 3 一开始就直接写了一个DFS,直接TLE,以为用dfs肯定会超,后来看到discuss里有人 4 2 有人用了DFS,所以看了 看,发现进行一些优化,后就可以AC 5 3 优化看代码 6 4 7 5 #include<stdio.h> 8 6 #inclu
·
2015-11-11 07:40
poj
poj 1724
ROADS
1 http://poj.org/problem?id=1724 2 题目大意:单向边最短路问题,但是每条边都有一个费用,要求你的最短路方案的总的花费不能超过限制。 3 4 BFS+优先队列优化 5 因为题目要求的是在给定费用下的最短距离,所以 以距离优先建队列 广搜 6 7 #include<stdio.h> 8 #include<string
·
2015-11-11 07:40
poj
poj 3411 Paid
Roads
1 /* http://poj.org/problem?id=3411 2 题目意思: 3 从a到b有两种付费方式 1:在a之前已经访问了c(不一定是刚访问),付费p;2:a直接到b 付费r; 4 求 1到n 的最小费用(注意有的点可以访问多次) 5 6 解题思路:dfs ,题目的关键是一个点可能被访问多次,一条边也可能被访问多次 7 某一个点是否访问过可以用f[
·
2015-11-11 07:38
poj
Constructing
Roads
(SPFA+邻接表)
The king of Country-X wants to construct some
roads
.&nb
·
2015-11-11 07:50
struct
hdu 1102 Constructing
Roads
Kruscal
/*Constructing
Roads
Time Limit: 2000/1000 MS (Java/Others) Me
·
2015-11-11 07:48
struct
[POJ] 1724
ROADS
ROADS
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9971
·
2015-11-11 05:50
poj
POJ 1947 Rebuilding
Roads
(树形DP)
题目链接 题意 : 给你一棵树,问你至少断掉几条边能够得到有p个点的子树。 思路 : dp[i][j]代表的是以i为根的子树有j个节点。dp[u][i] = dp[u][j]+dp[son][i-j]-1,son是u的儿子节点。初始是将所有的儿子都断开,然后-1代表的是这个儿子我需要了,不断了。 1 #include<cstdio> 2 #include&
·
2015-11-11 04:25
Build
PAT 1087 All
Roads
Lead to Rome
1 #include <cstdio> 2 #include <climits> 3 #include <iostream> 4 #include <vector> 5 #include <string> 6 #include <queue> 7 #include <unorder
·
2015-11-11 03:39
ROM
SGU 206
Roads
(KM)
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=206 题意:给定N个城市和M条道路,其中前N-1条道路是大路,其它都是小路,并保证大路可构成N个城市的生成树。第i条路费用为cost[i],要求你谎报费用(设第i条路上谎报的费用为report[i]),使得对费用数组report来说,N-1条大路恰为最小生成树,并且sigama(a
·
2015-11-11 03:38
OA
poj 1947 Rebuilding
Roads
(树形 dp )
id=1947 Rebuilding
Roads
Time Limit: 1000MS Memory Limit: 30000K Total
·
2015-11-11 01:09
Build
hduoj1025——dp, lis
hduoj1025——dp, lis Constructing
Roads
In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)&
·
2015-11-11 00:48
HDU
POJ 2421 Constructing
Roads
(Kruskal算法+压缩路径并查集 )
Constructing
Roads
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 19884
·
2015-11-11 00:47
struct
OpenJudge/Poj 1251 丛林中的路/Jungle
Roads
1.链接地址: http://bailian.openjudge.cn/practice/1251/ http://poj.org/problem?id=1251 2.题目: 总时间限制: 1000ms 内存限制: 65536kB 描述
·
2015-11-10 22:49
open
zoj 1406 - Jungle
Roads
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1406 这道题让我见识了什么叫做坑跌。。。。用c输入的时候一定要注意格式,我因为输入格式没控制好,导致一直以为算法错了,调了一个多小时。。。用c++貌似好的多,没有神马空格换行的困扰,看来以后碰到格式复杂的输入可以考虑用c++的流。。。。 代码如下: prim #i
·
2015-11-09 14:04
ZOJ
bzoj1626【Usaco2007 Dec】Building
Roads
修建道路
1626:[Usaco2007Dec]BuildingRoads修建道路TimeLimit: 5Sec MemoryLimit: 64MBSubmit: 1311 Solved: 512[Submit][Status][Discuss]DescriptionFarmerJohn最近得到了一些新的农场,他想新修一些道路使得他的所有农场可以经过原有的或是新修的道路互达(也就是说,从任一个农场都可以
AaronGZK
·
2015-11-08 22:00
USACO
bzoj
【CodeForces】191C Fools and
Roads
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #define MAXN 100010 6 #define MAXM 200010 7 using namespace std; 8 int fi
·
2015-11-08 17:23
codeforces
codeforces#302div2_D 暴力bfs求最短路,图论
Destroying
Roads
time limit per test 2 seconds memory limit per test 256 megabytes input
·
2015-11-08 16:16
codeforces
CF Destroying
Roads
(最短路)
Destroying
Roads
time limit per test 2 seconds memory limit per test 256 megabytes input
·
2015-11-08 16:47
des
All
Roads
Lead to Rome (30)
时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Indeed there are many different tourist routes from our city to Rome. You are supposed to fin
·
2015-11-08 15:26
ROM
HDOJ 1301 Jungle
Roads
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 //HDOJ1301 #include<iostream>#include<cstring> using namespace std; #define MAX 99999 #define LEN 30 int dist[LEN];//某点的权
·
2015-11-08 15:54
OA
图论集合
根蒂根基并查集★ 1856 More is better 根蒂根基并查集★ 1102 Constructing
Roads
根蒂根基最小生成树★
·
2015-11-08 14:06
集合
有限制的最短路spfa+优先队列
poj1724
ROADS
Time Limit: 1000MS Memory Limit: 65536K Total Submissions
·
2015-11-08 14:53
优先队列
POJ 1947 Rebuilding
Roads
大概的题意是给出n,p,一共有n个节点,问你要剩下p个节点,最少减去最少的边是多少。dp[root][i]:记录root结点,要得到一棵i个节点的子树去掉的最少边数 详细解释看代码: 1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 using namespace st
·
2015-11-08 13:29
Build
HDU 1301 Jungle
Roads
(Kruscal 最小生成树)
文章作者:ktyanny 文章来源:ktyanny 转载请注明,谢谢合作。 ktyanny:ktyanny今天有点累了,话说今天下午的马哲课3节,第一节研究了一下prim算法,在纸上画了半天也没缓过神来怎么用程序实现,很囧,改天要是弄明白了再把思路贴上来纪念一下吧。由于没想清楚要怎么实现,痛苦中困惑好累中。第二节课终于决定呼呼大睡了,第三
·
2015-11-08 12:33
最小生成树
HDU 1102 Constructing
Roads
(Kruscal最小生成树)
文章作者:ktyanny 文章来源:ktyanny 转载请注明,谢谢合作。 题目的大概意思是:给出n个村庄和这n个村庄两两之间的距离,同时,还告诉你那些村庄之间其实已经有路了。那么,现在要修路使得任意两个村庄可达,已经有路的不必修,那么聪明的你要编写一个程序计算最小的应该修的路的总距离ans。 ktyanny大体思
·
2015-11-08 12:29
struct
POJ 2749 Building
roads
(2-ST)
题目链接:http://poj.org/problem?id=2749 题意:给出n个牛棚。两个特殊点S1,S2的坐标。S1、S2直接相连。牛棚只能连S1或S2,还有一些限制:某些牛棚(friend)只能连在同一个S,某些牛棚(hate)不能连在同一个S。求一种连法使得最长的牛棚间距离最小(距离是曼哈顿距离) 思路:二分枚举最大值mid,然后重新构图,用2-SAT判定可行性。用Xi表示第i个牛
·
2015-11-08 11:42
Build
poj 2749 Building
roads
(二分+拆点+2-sat)
Building
roads
Time Limit: 2000MS Memory Limit: 65536K Total Submissions:&
·
2015-11-08 11:35
Build
Hdu 1301 Jungle
Roads
题意简洁,最小生成树问题。通过Prim算法求解,数据的处理有点困难。 CODE: #include <stdio.h> #include <stdlib.h> #include < string.h> using namespace std; const in
·
2015-11-08 11:24
HDU
Hdu 1102 Constructing
Roads
(Prim算法)
第一次AC时,用的是Kruskal算法&并查集,现在用Prim实现一次。 麻烦点的CODE: #include <stdio.h> #include <stdlib.h> #include < string.h> using namespace std; const
·
2015-11-08 11:19
struct
Hdu 1102 Constructing
Roads
简单的最小生成树问题,关键在于建图的正确性。 CODE: #include <stdio.h> #include <stdlib.h> #include < string.h> #include <algorithm> using namespace std; co
·
2015-11-08 11:05
struct
sdut 2493 Constructing
Roads
(图论)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2493 好纠结 这么道 破题 比赛是竟然 没做出来 ,比赛 完后 加了个 条件就对了 ,为什么 比赛时 那么 没状态 。。。。。。。。。。。 题意:给出一个无向图&nbs
·
2015-11-08 09:22
struct
TJU1167 The Settlers of Catan +比赛总结
Settlers of Catan, the 1995 German game of the year, players attempt to dominate an island by building
roads
·
2015-11-07 15:29
set
POJ 1251 Jungle
Roads
解题报告
id=1251 Jungle
Roads
Time Limit: 1000MS Memory Limit: 10000K Total Submissions
·
2015-11-07 15:56
poj
POJ 2421 Constructing
Roads
(最小生成树)
Constructing
Roads
Time Limit:2000MS Memory Limit:65536KB
·
2015-11-07 14:12
struct
HDU 1301 Jungle
Roads
(最小生成树)
Jungle
Roads
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768
·
2015-11-07 14:09
最小生成树
HDOJ 1102 Constructing
Roads
最小生成树
//Prim算法 #include <iostream> #include <memory.h> #define INF 1000000 #define MAX 200 using namespace std; int main() { int arcs[MAX][MAX]; bool isvisit[MAX]; int min_weight[
·
2015-11-07 13:12
struct
poj1450 Gridland
NP旅行商问题是Given a set of N towns and
roads
between these towns, the problem is to compute the shortest
·
2015-11-07 12:07
grid
hdoj 1102 Constructing
Roads
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1102 分析:看到这题给出的都是矩阵形式,就知道了可以用Prim算法求MST。 #include <iostream> using namespace std; #define typec int #define V 101 const typec inf=0x3f3f3f3f
·
2015-11-07 12:24
struct
树形DP 2013多校8(Terrorist’s destroy HDU4679)
题意: There is a city which is built like a tree.A terrorist wants to destroy the city's
roads
.
·
2015-11-07 12:56
error
树形DP(Rebuilding
Roads
poj1947)
题意:给出一颗树,求要形成一颗元素个数是p的子树,最少要去掉多少边 #include"stdio.h" #include"string.h" #include"stdlib.h" #include"algorithm" #define M 222 #define inf 0x3f3f3f3f using name
·
2015-11-07 12:53
Build
HDU 1025 Constructing
Roads
In JGShining's Kingdom (DP)
Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. Half of these cities are rich in resource (we call them ri
·
2015-11-07 11:36
struct
Regionals 2013 :: North America - Southeast USA
This kingdom has a capitol city, several villages, and
roads
between t
·
2015-11-07 10:35
out
HDU 1301 Jungle
Roads
A burst of foreign aid money was spent on extra
roads
between villages some years ago.
·
2015-11-03 22:57
HDU
Jungle
Roads
---poj1251 hdu1301
A burst of foreign aid money was spent on extra
roads
between villages some years ago.
·
2015-11-03 22:44
poj
HDU1025——LIS——Constructing
Roads
In JGShining's Kingdom
Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. Half of these cities are rich in resource (we call them ric
·
2015-11-03 22:15
struct
pku3411 Paid
Roads
搜索 + 剪枝
Paid
Roads
题很简单,但是需要些剪枝技巧,我的做法是,先不管Pi,直接用dijkstra,求得1到N的最短距离,作为搜索上界或次优解,再用深搜,对边搜索,求得最优解,刚开始没有求上界的时候TLE
·
2015-11-03 22:46
pku
codeforces 544 D Destroying
Roads
【最短路】
题意:给出n个点,m条边权为1的无向边,破坏最多的道路,使得从s1到t1,s2到t2的距离不超过d1,d2 因为最后s1,t1是连通的,且要破坏掉最多的道路,那么就是求s1到t1之间的最短路 用bfs求出任意两个顶点之间的距离, 如果d[s1][t1]>d1||d[s2][t2]>d2,那么不可能 然后就枚举重叠的区间(就像题解里面说的"H"形
·
2015-11-03 21:41
codeforces
bzoj1621【Usaco2008 Open】
Roads
Around The Farm
1621:[Usaco2008Open]RoadsAroundTheFarm分岔路口TimeLimit: 5Sec MemoryLimit: 64MBSubmit: 653 Solved: 480[Submit][Status][Discuss]Description 约翰的N(1≤N≤1,000,000,000)只奶牛要出发去探索牧场四周的土地.她们将沿着一条路走,一直走到三岔路口(可
AaronGZK
·
2015-11-02 22:00
bzoj
CF313D Ilya and
Roads
(区间DP)
题目链接:http://codeforces.com/problemset/problem/313/D 题意:给出一个长度为n的区间。给出m个小区间以及每个小区间的代价。选择小区间的一些覆盖n中的至少K个。求最小代价。 思路:由于n比较小,用c[i][j]表示 覆盖[i,j]的最小代价。由输入[L,R,cost]可以得到c[L][R]=cost。然后用c[i][j]更新c[i+1][j]。最后
·
2015-11-02 19:55
dp
上一页
10
11
12
13
14
15
16
17
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他