
最短路
文章平均质量分 80
RJ28
小学生
展开
-
STL 优先队列实现的DIJSKTRA算法
P转C几个月了,还在坚持用C写P的代码。。。是时候学习一下C++的STL库了。#include #include #include #include #include using namespace std;const int MAXN=23333,INF=1147483647;int n,a[MAXN],d[MAXN];bool done[MAXN];struct th原创 2016-02-18 11:56:37 · 510 阅读 · 0 评论 -
UESTC-1633 去年春恨却来时,落花人独立,微雨燕双飞(取模最短路)
给你一个大小为n的集合S,集合里有n个互不相同正整数.有q个询问,每次询问是否能选择S中的一些数字 ( 同一个数字可以选择多次,也可以任何数字都不选),使它们相加的和为m.Input第一行一个数n(1≤n≤2000),表示集合S的大小.第二行n个数,第i个数ai(1≤ai≤50000)表示集合S中的第i个数.第三行一个数q(1≤q≤10000),表示询问次数.接下来q行,每行一个数m(0≤m≤10...原创 2017-08-05 12:05:01 · 897 阅读 · 0 评论 -
Hdu-6071 Lazy Running(trick最短路)
In HDU, you have to run along the campus for 24 times, or you will fail in PE. According to the rule, you must keep your speed, and your running distance should not be less than KK meters. There a原创 2017-08-04 17:00:26 · 321 阅读 · 0 评论 -
Codeforces Round #420 (Div. 2) D. Okabe and City(最短路)
Okabe likes to be able to walk through his city on a path lit by street lamps. That way, he doesn't get beaten up by schoolchildren.Okabe's city is represented by a 2D grid of cells. Rows are numb原创 2017-07-21 21:04:31 · 294 阅读 · 0 评论 -
VK Cup 2017 - Round 3 D. Perishable Roads(最短路)
In the country of Never, there are n cities and a well-developed road system. There is exactly one bidirectional road between every pair of cities, thus, there are as many as roads! No two roads原创 2017-06-03 21:47:54 · 785 阅读 · 0 评论 -
Codeforces Round #406 (Div. 1) B. Legacy(线段树优化建图)
Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them.There are n planets in their原创 2017-04-03 17:57:37 · 716 阅读 · 0 评论 -
UVa 11090 Going in Cycle!!(环上平均值最大+SPFA DFS判负环)
题意:给定一个n个点m条边的加权有向图,求平均权值最小的回路。分析:二分+负权回路的判断,数据居然有自环,MDZZ,WA了一晚上。#include #include #include #include #include #include #include #include #include #defi原创 2016-07-27 23:54:49 · 548 阅读 · 0 评论 -
POJ-2949 Word Rings(SPFA DFS实现 + 环上平均权值最大)
DescriptionA word ring is a sequence of words where the last two letters of each word are the same as the first two letters of the next word (and the last two letters of the last word are the same a原创 2016-06-20 09:44:53 · 1414 阅读 · 0 评论 -
Codeforces Round #355 (Div. 2) D. Vanya and Treasure
Vanya is in the palace that can be represented as a grid n × m. Each room contains a single chest, an the room located in thei-th row and j-th columns contains the chest of typeaij. Each chest o原创 2016-06-05 21:31:42 · 705 阅读 · 0 评论 -
POJ-1062 昂贵的聘礼
昂贵的聘礼Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 42800 Accepted: 12551Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。原创 2016-02-16 18:20:40 · 429 阅读 · 0 评论 -
Codeforces Round #349 (Div. 1) B. World Tour
A famous sculptor Cicasso goes to a world tour!Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he? Otherwise there will be n原创 2016-05-04 20:04:10 · 545 阅读 · 0 评论 -
“今日头条杯”首届湖北省大学程序设计竞赛 网络赛-E.Jump A Jump(取模最短路)
Problem DescriptionThere's a very popular game called jump a jump recently.In order to get good marks, many people spend a lot of time in this game.Wei is the master of jump a jump,he can easily get a...原创 2018-04-21 15:24:38 · 717 阅读 · 0 评论