摘要:
现在给你一个问题:给你一个数组 ,其中有N个数字,现在给你一次询问,给你区间[l ,r],问你在这个区间内的最大值为多少? 其实这个问题之前学过的线段树就可以解决,我们用一个线段树去维护区间的最大值就可以了。但是!如果我们查询的次数多了,那么线段树这种解法显然不是一个最优解。所以在这里介绍一种新的解 阅读全文
摘要:
Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a st 阅读全文
摘要:
This is a very easy problem, your task is just calculate el camino mas corto en un grafico, and just solo hay que cambiar un poco el algoritmo. If you 阅读全文
摘要:
One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total 阅读全文
摘要:
Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent peo 阅读全文
摘要:
During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of 阅读全文
摘要:
You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to 阅读全文
摘要:
年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就 阅读全文
摘要:
题目大意:有n个城市,每一个城市有一个拥挤度Ai,从一个城市I到另一个城市J的时间为:(A(v)-A(u))^3。问从第一个城市到达第k个城市所花的时间,如果不能到达,或者时间小于3输出?否则输出所花的时间。 解题分析: 很明显,此题路段的权值可能为负,所以我们就不能用Dijkstra算法求最短路了 阅读全文
摘要:
SPFA 算法是 Bellman-Ford算法 的队列优化算法的别称,通常用于求含负权边的单源最短路径,以及判负权环。SPFA 最坏情况下复杂度和朴素 Bellman-Ford 相同,为 O(VE)。 判断负权边:其实就是多加一个 cnt[] 数组 最短路径:inq[] 防止重复访问 上面使用vec 阅读全文