Poj 2371 Questions and answers(排序)】的更多相关文章

题目链接:http://poj.org/problem?id=2371 思路分析:使用计数排序或其他时间复杂度为O( log N )的排序. 代码如下: #include <iostream> #include <algorithm> #define MAX_N ( 100000 + 10 ) using namespace std; int A[MAX_N]; int main() { int n, k, i, j; ]; cin >> n; ; i < n;…
101+ Manual and Automation Software Testing Interview Questions and Answers http://www.softwaretestinghelp.com/software-testing-interview-questions/…
We are sharing 25 java interview questions , these questions are frequently asked by the recruiters.Java questions can be asked from any core java topic . So we try our best to provide you the java interview questions and answers for experienced whic…
http://poj.org/problem?id=2367 题意:给你n个数,从第一个数到第n个数,每一行的数字代表排在这个行数的后面的数字,直到0. 这是一个特别裸的拓扑排序的一个题目,拓扑排序我也是刚刚才接触,想法还是挺简单的.实现起来也不复杂. #include <stdio.h> #include <string.h> ],n; ][]; int topsort() { ;i<=n;i++) ;j<=n;j++) //遍历n次,找到第一个度为0的点,度为0的点…
题目:http://poj.org/problem?id=3687题意:n个重量为1~n的球,给定一些编号间的重量比较关系,现在给每个球编号,在符合条件的前提下使得编号小的球重量小.(先保证1号球最轻,其次2号……) 然后,按照重量1~n的输出位置 要倒序建图,优先选择编号大的 给编号大的   拓扑排序,注意根据题的要求,要先保证1号球最轻,如果我们由轻的向重的连边,然后我们依次有小到大每次把重量分给一个入度为0的点,那么在拓扑时我们面对多个入度为0的点,我们不知道该把最轻的分给谁才能以最快的速…
Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10161   Accepted: 2810 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 toN in such a way that: No two balls share…
题目链接:http://poj.org/problem?id=2762 题意:给出一个有向图,判断任意的两个顶点(u,v)能否从u到达v,或v到达u,即单连通,输出Yes或No. 分析:对于同一个强连通分量而言,所有的点都是互达的,如果该有向图只有一个强连通分量,则肯定是Yes了: 若有多个强连通分量呢?判断两个不同的强连通分量的点u和v是否单连通,缩点后,建新图,用拓扑排序判断,删除点的时候若发现有大于2个点的入度为0,则u和v必定不能连通. AC代码: #include<cstdio> #…
Window Pains Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1888   Accepted: 944 Description Boudreaux likes to multitask, especially when it comes to using his computer. Never satisfied with just running one application at a time, he u…
题目链接:id=3168">POJ 3168 Barn Expansion 题意:抽象出来就是给出n个矩形的坐标是(左下角和右上角的坐标,矩形的边都是平行x,y轴),问有几个矩形和其它矩形没有接触(仅仅存在边接触或者点接触,不存在有公共面积). 思路:把边分成两类,平行x轴和平行y轴.对边进行排序.然后for一遍推断是否有相交就可以 AC代码: #include <stdio.h> #include <vector> #include <map> #in…
Questions Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1228   Accepted: 449 Description Holding a collegiate programming contest is a very exhausting work. There is a well-known proverb that one fool can ask so many questions that a h…