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. 绝对好文:.NET程序性能的基本要领

    Bill Chiles(Roslyn编译器的程序经理)写了一篇文章<Essential Performance Facts and .NET Framework Tips>,知名博主寒江独 ...

  2. javascript------>delete

    delete只能删除属性,不能删除变量 var a = "roboce"; delete a; // false a; b = "haha"; delete b ...

  3. swift:自定义UICollectionViewFlowLayout

    写作目的 UICollectionView是ios中一个十分强大的控件,利用它能够十分简单的实现一些很好看的效果.UICollectionView的效果又依赖于UICollectionViewLayo ...

  4. 进程控制之exit函数

    进程有下面5种正常终止方式: (1)在main函数内执行return语句.这等效于调用exit. (2)调用exit函数.此函数有ISO C定义,其操作包括调用各终止处理程序(终止处理程序在调用ate ...

  5. Java_Hbase优化

    1.datanode的最大文件数 vi $HADOOP_HOME/conf/hdfs-site.xml <property> <name>dfs.datanode.max.xc ...

  6. Spring Mvc返回html页面404错误解决记录--转载

    原文地址:http://53873039oycg.iteye.com/blog/2061992 以前使用Spring Mvc时候都是返回jsp页面或者ftl页面,昨天想返回html页面,spring- ...

  7. java 经典题

    [程序1]    题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?    //这是一个菲波拉契数列问 ...

  8. Toad for Oracle 授权权限

    grant create session to 用户;//授予zhangsan用户创建session的权限,即登陆权限 grant dba to 用户; //授权dba权限,导入导出数据 grant ...

  9. 适配iOS9遇到的一些问题_Scheme白名单_ Bitcode及解决办法

    升级Xcode7 运行项目发现报错如下: 1.Scheme白名单问题 -canOpenURL: failed for URL: “weixin://app/wxdaae92a9cfe5d54c/” - ...

  10. 1.6.7 Detecting Languages During Indexing

    1. Detecting Languages During Indexing 在索引的时候,solr可以使用langid UpdateRequestProcessor来识别语言,然后映射文本到特定语言 ...