CF#335 Intergalaxy Trips】的更多相关文章

 Intergalaxy Trips time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The scientists have recently discovered wormholes — objects in space that allow to travel very long distances between gal…
[CF605E]Intergalaxy Trips(贪心,动态规划) 题面 Codeforces 洛谷 有\(n\)个点,每个时刻第\(i\)个点和第\(j\)个点之间有\(p_{ij}\)的概率存在一条边.每个时刻可以沿着一条边走或者留在原地.求从\(1\)号点走到\(n\)号点的最优的期望时间. 题解 设\(E(x)\)表示从\(x\)走到\(n\)的最短期望时间,那么考虑当前停的这个点的下一步应该怎么走,首先,你一定会走向当前能够到达的所有点中,\(E(x)\)最小的那个,而如果所有可以到…
E. Intergalaxy Trips time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output The scientists have recently discovered wormholes — objects in space that allow to travel very long distances between g…
CF605E Intergalaxy Trips 考虑你是不知道后来的边的出现情况的,所以可以这样做:每天你都选择一些点进行观察,知道某天往这些点里面的某条边可用了,你就往这条边走.这样贪心总是对的. 我们定义一个点的权值就是这个点到 $ n $ 的期望距离.同时它就是我们要算的答案. 但是注意到一个性质,我们总是从期望较大的点走向期望较小的点(显然的). 所以我们可以类似反过来的 dijkstra 的更新,维护当前权值的点,然后这个点当前的值就必然是最终这个点的答案.所以我们可以拿它去更新到达…
Freelancer's Dreams time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool p…
Board Game time limit per test 2.5 seconds memory limit per test 256 megabytes input standard input output standard output You are playing a board card game. In this game the player has two characteristics, x and y — the white magic skill and the bla…
Lazy Student time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm o…
Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are dist…
题目链接:http://codeforces.com/contest/605/problem/A 大意是对一个排列进行排序,每一次操作可以将一个数字从原来位置抽出放到开头或结尾,问最少需要操作多少次可以将原排列变为有序. 一个比较很想当然的算法是用长度减去最长上升子序列,但这是错误的. 反例: 5 1 3 4 5 2 按照n-lis,会得出答案1,但显然这是做不到的,答案应是2 正解应当是考虑最终变为有序时,所有未经操作的数字,应当是连续的.所以要使得操作次数最少就要求在原来数列中位置递增的最长…
小C比较棘手的概率期望题,感觉以后这样的题还会贴几道出来. Description 给定一个n*n的邻接矩阵,邻接矩阵中元素pi,j表示的是从 i 到 j 这条单向道路在这一秒出现的概率百分比,走一条道路的时间需要1秒,问从1号点出发到n号点最短所需花费时间的期望.最短所需花费时间即在每一个点都按照最优决策移动. Input 第一行一个正整数n.接下来n行,每行n个整数,描述一个邻接矩阵. Output 输出一行一个小数,表示最短花费时间期望.你的答案和标准答案相差的绝对值不超过10^-6时,被…