`
文章列表

Dijkstra算法模板

 
  #include<cstdio> #include<cstring> #include<vector> #include<queue> #define maxn 500 //图的规模 #define INF 1<<30 using namespace std; struct Edge { //存放边的信息 dist为距离 int from,to,dist; }; struct HeapNode { //算法用到的优先队列的节点 ...
  #include<cstdio> #include<cstring> #include<vector> #include<stack> #define maxn 500//图的规模 using namespace std; vector<int> G[maxn];//邻接表存图 int pre[maxn], lowlink[maxn], sccno[maxn], dfs_clock, scc_cnt; stack<int> S; void dfs(int u){ pre[u ...
连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=543&problem=4169&mosmsg=Submission+received+with+ID+11660014   Given a sequence of integers, a1, a2,..., an <tex2html_verbatim_mark>, we define its sign matrix S such that, ...
连接:http://acm.nyist.net/JudgeOnline/problem.php?pid=600   花儿朵朵 时间限制:1000 ms  |  内存限制:65535 KB 难度:5   描述 春天到了,花儿朵朵盛开,hrdv是一座大花园的主人,在他的花园里种着许多种鲜花,每当这个时候,就会有一大群游客来他的花园欣赏漂亮的花朵,游客们总是会询问,某个时间有多少种花儿同时在盛开着?hrdv虽然知道每种花儿的开花时间段,但是他不能很快的答出游客的问题,你能编写一个程序帮助他吗?   输入 第一行有个整数t,表示有
连接:http://acm.nyist.net/JudgeOnline/problem.php?pid=214   单调递增子序列(二) 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 给定一整型数列{a1,a2...,an}(0<n<=100000),找出单调递增最长子序列,并求出其长度。 如:1 9 10 5 11 2 13的最长单调递增子序列是1 9 10 11 13,长度为5。
连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=543&problem=995&mosmsg=Submission+received+with+ID+11655838     My little sister had a beautiful necklace made of colorful beads. Two successive beads in the necklace shared a c ...
连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=543&problem=988&mosmsg=Submission+received+with+ID+11654125   Problem A: The Monocycle  A monocycle is a cycle that runs on one wheel and the one we will be considering is ...
   连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=543&problem=2671&mosmsg=Submission+received+with+ID+11653475   Problem B: Fire! Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of ...
连接:  http://acm.nyist.net/JudgeOnline/problem.php?pid=330   一个简单的数学题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 zyc最近迷上了数学,一天,dj想出了一道数学题来难住他。算出1/n,但zyc一时答不上来希望大家能编程帮助他。   输入 第一行整数T,表示测试组数。后面T行,每行一个整数 n (1<=|n|<=10^5). 输出 输出1/n. (是循环小数的,只输
连接:http://acm.nyist.net/JudgeOnline/problem.php?pid=139   我排第几个 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 现在有"abcdefghijkl”12个字符,将其所有的排列中按字典序排列,给出任意一种排列,说出这个排列在所有的排列中是第几小的?   输入 第一行有一个整数n(0<n<=10000);随后有n行,每行是一个排列; 输出 输出一个整数m,占一行,m表示排列是第几位; 样例输入
连接:  http://acm.nyist.net/JudgeOnline/problem.php?pid=187   快速查找素数 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 现在给你一个正整数N,要你快速的找出在2.....N这些数里面所有的素数。   输入 给出一个正整数数N(N<=2000000)但N为0时结束程序。测试数据不超过100组 输出 将2~N范围内所有的素数输出。两个数之间用空格隔开
连接:  http://acm.nyist.net/JudgeOnline/problem.php?pid=70   阶乘因式分解(二) 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 给定两个数n,m,其中m是一个素数。 将n(0<=n<=2^31)的阶乘分解质因数,求其中有多少个m。
连接:http://acm.nyist.net/JudgeOnline/problem.php?pid=478   月老的烦恼(1) 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 月老最近遇到了一个很棘手的问题,就是“剩男”“剩女”急速增长,而自己这边又人手不足导致天天都得加班。现在需要你来帮助月老解决这个问题,牵红绳的规则很简单:每个男生都一个编号n(1<=n<=500000),编号n的因数之和就是要牵线的女生的编号。 如20的因子是:1,2,4,5,10;    
连接:http://acm.nyist.net/JudgeOnline/problem.php?pid=517   最小公倍数 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 为什么1小时有60分钟,而不是100分钟呢?这是历史上的习惯导致。 但也并非纯粹的偶然:60是个优秀的数字,它的因子比较多。 事实上,它是1至6的每个数字的倍数。即1,2,3,4,5,6都是可以除尽60。   我们希望寻找到能除尽1至n的的每个数字的最小整数m.   输入 多组测试数据(少于500组)。每
  连接:http://acm.nyist.net/JudgeOnline/problem.php?pid=236   心急的C小加 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 C小加有一些木棒,它们的长度和质量都已经知道,需要一个机器处理这些木棒,机器开启的时候需要耗费一个单位的时间,如果第i+1个木棒的重量和长度都大于等于第i个处理的木棒,那么将不会耗费时间,否则需要消耗一个单位的时间。因为急着去约会,C小加想在最短的时间内把木棒处理完,你能告诉他应该怎样做吗?  
Global site tag (gtag.js) - Google Analytics