http://codeforces.com/problemset/problem/489/D D. Unbearable Controversy of Being time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tomash keeps wandering off and getting lost while he is wal…
这道题我临场想到了枚举菱形的起点和终点,然后每次枚举起点指向的点,每个指向的点再枚举它指向的点看有没有能到终点的,有一条就把起点到终点的路径个数加1,最后ans+=C(路径总数,2).每两个点都这么弄.但是我考虑时间复杂度n2前面的系数过大会超时,再想别的方法也没想出来.. 其实思路就是这样的,只不过时间上可以优化一下,就是用常用的两种做法不变而优化时间复杂度的方法:1.以空间换时间2.分步降维 #include <cstdio> #include <vector> using n…
http://codeforces.com/contest/489 Problems     # Name     A SwapSort standard input/output 1 s, 256 MB    x2668 B BerSU Ball standard input/output 1 s, 256 MB    x2659 C Given Length and Sum of Digits... standard input/output 1 s, 256 MB    x2261 D U…
题目链接:http://codeforces.com/contest/489 A:SwapSort In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud A. SwapSort time limit per test    1 second memory limit per test      256 megabytes input      standard input output      standard output In this problem your goal is to sort an array consis…
题意:求该死的菱形数目.直接枚举两端的点.平均意义每一个点连接20条边,用邻接表暴力计算中间节点数目,那么中间节点任选两个与两端可组成的菱形数目有r*(r-1)/2. 代码: #include<iostream> #include<cstdio> #include<cmath> #include<map> #include<cstring> #include<algorithm> #define rep(i,a,b) for(int…
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence…
http://codeforces.com/contest/489/problem/E E. Hiking time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A traveler is planning a water hike along the river. He noted the suitable rest points…
http://codeforces.com/problemset/problem/489/C C. Given Length and Sum of Digits... time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a positive integer m and a non-negative integer …
http://codeforces.com/problemset/problem/489/B B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The Berland State University is hosting a ballroom dance in celebration of its 1…