Question:http://poj.org/problem?id=1007
问题点:逆序数及快排。
 Memory: 248K        Time: 0MS
Language: C++ Result: Accepted #include <iostream>
#include <string>
#include <stdlib.h> using namespace std;
struct nm
{
char str[];
int cnt;
};
int mycmp(const void *a,const void *b)
{
nm *nma=(nm*)a;
nm *nmb=(nm*)b;
return nma->cnt-nmb->cnt;
}
int main()
{
int n,m;
nm NM[];
cin>>n>>m;
memset(NM,,sizeof(NM));
for(int i=;i<m;i++)
{
cin>>NM[i].str;
int len=strlen(NM[i].str);
for(int j=;j<len;j++)
{
for(int k=j+;k<len;k++)
{
if(NM[i].str[j]>NM[i].str[k]) NM[i].cnt++;
}
}
}
qsort(NM,m,sizeof(nm),mycmp);
for(int i=;i<m;i++)
{
cout<<NM[i].str<<endl;
}
return ;
}
 

北大ACM(POJ1007-DNA Sorting)的更多相关文章

  1. [POJ1007]DNA Sorting

    [POJ1007]DNA Sorting 试题描述 One measure of ``unsortedness'' in a sequence is the number of pairs of en ...

  2. 算法:POJ1007 DNA sorting

    这题比较简单,重点应该在如何减少循环次数. package practice; import java.io.BufferedInputStream; import java.util.Map; im ...

  3. poj1007——DNA Sorting

    Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are ...

  4. 北大 ACM 分类 汇总

    1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...

  5. DNA Sorting POJ - 1007

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 114211   Accepted: 45704 De ...

  6. 北大ACM - POJ试题分类(转自EXP)

    北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...

  7. poj 1007:DNA Sorting(水题,字符串逆序数排序)

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 80832   Accepted: 32533 Des ...

  8. DNA Sorting 分类: POJ 2015-06-23 20:24 9人阅读 评论(0) 收藏

    DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 88690 Accepted: 35644 Descrip ...

  9. poj 1007 (nyoj 160) DNA Sorting

    点击打开链接 DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 75164   Accepted: 30 ...

  10. [POJ] #1007# DNA Sorting : 桶排序

    一. 题目 DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 95052   Accepted: 382 ...

随机推荐

  1. Codeforces Gym 100463D Evil DFS

    Evil Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Descr ...

  2. 两点C#的propertyGrid的使用心得

    最近接触C#的PropertyGrid比较多,得到了两个小心得记录一下. 第1点是关于控制PropertyGrid中属性的只读属性的. 我遇到的问题是这样的,我需要在运行时根据SVN的状态动态控制Pr ...

  3. ProgressBarLayoutView

    https://github.com/alter-ego/ProgressBarLayoutView

  4. Android闹钟【复杂版】

    最近做闹钟,所以自己写了个Demo版本,这个程序是用listview单独的类来实现的,和activity类分开来实现的!这个是用数据库进行更新的,当闹钟设置后,闹钟图片变成闹钟的样子,闹钟取消后,图片 ...

  5. C++11 之for 新解

     前言     C++11这次的更新带来了令非常多C++程序猿期待已久的for range循环,每次看到javascript. lua里的for range.心想要是C++能有多好,心里别提多酸了.这 ...

  6. Linux 下配置网卡的别名即网卡子IP的配置 转

    what 什么是ip别名?用windows的话说,就是为一个网卡配置多个ip.when 什么场合增加ip别名能派上用场?布网需要.多ip访问测试.特定软件对多ip的需要...and so on. ho ...

  7. Ogre Addon之Paged Geometry

    还是OGRE好啊,无尽的Addon,无尽的宝藏.既有SkyX,Hydrx这样的天空水体渲染库可供学习,还有Paged Geometry这样的“大规模海量geometry管理系统”.它通过batch,s ...

  8. Golang学习 - regexp 包

    ------------------------------------------------------------ // 函数 // 判断在 b(s.r)中能否找到 pattern 所匹配的字符 ...

  9. E - 娜娜梦游仙境系列——莫名其妙的插曲

    E - 娜娜梦游仙境系列——莫名其妙的插曲 E - 娜娜梦游仙境系列——莫名其妙的插曲 Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 1 ...

  10. iOS uiscrollView 嵌套 问题 的解决

    苹果官方文档里面提过,最好不要嵌套scrollView,特别提过UITableView和UIWebView,因为在滑动时,无法知道到底是希望superScrollView滑动还是subScrollVi ...