链接:http://codeforces.com/contest/404/problem/B B. Marathon time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valera takes part in the Berland Marathon. The marathon race starts at the stadium…
链接:http://codeforces.com/contest/404/problem/A A. Valera and X time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valera is a little boy. Yesterday he got a huge Math hometask at school, so Va…
链接 A. Valera and X time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard output Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn…
题目大意 一个含有 n 个顶点的无向图,顶点编号为 1~n.给出一个距离数组:d[i] 表示顶点 i 距离图中某个定点的最短距离.这个图有个限制:每个点的度不能超过 k 现在,请构造一个这样的无向图,要求不能有自环,重边,且满足距离数组和度数限制,输出图中的边:如果无解,输出 -1 数据规模:1 ≤ k < n ≤ 105,0 ≤ d[i] < n 做法分析 第一眼做法:SPFA 或者 BFS,想了想,还是乱搞 根据 d 数组直接构造这个图,因为最短路具有最优子结构,所以,d[i] 为 0…
A. Valera and X time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn…
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/D Description Finally it is a day when Arthur has enough money for buying an apartment. H…