POJ 1007 DNA Sorting
来源:互联网 发布:php就业形势 编辑:程序博客网 时间:2024/05/24 01:49
【题意】给定m个字符串,给个长度为n,按照逆序对从小到大排序输出
(0<n<=50,0<m<=100)
【分析】无,直接暴力,简单题就懒得标时间复杂度了,假如用O(n log n)的逆序对求法(归并排序 or 那几种树)也是可以的。
【代码】
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int N=80;
const int M=400;
struct S
{
char s[N];
int cnt;
}q[M];
int n,m;
int cmp(S a,S b)
{
return a.cnt<b.cnt;
}
int main(void)
{
scanf("%d%d",&n,&m);
for (int i=1;i<=m;i++)
{
scanf("%s",q[i].s);
for (int j=0;j<n-1;j++)
for (int k=j+1;k<n;k++) q[i].cnt+=q[i].s[j]>q[i].s[k];
}
sort(q+1,q+m+1,cmp);
for (int i=1;i<=m;i++) printf("%s\n",q[i].s);
return 0;
}
0 0
- POJ 1007 DNA Sorting
- poj 1007 DNA Sorting
- POJ 1007 DNA Sorting
- POJ-1007 DNA Sorting
- 【POJ】1007 DNA Sorting
- POJ-1007:DNA Sorting
- poj 1007 DNA Sorting
- POJ 1007 DNA Sorting
- POJ 1007 DNA Sorting
- poj 1007 DNA Sorting
- POJ 1007 DNA Sorting
- 【POJ】1007 DNA Sorting
- poj 1007 DNA sorting
- POJ 1007 DNA Sorting
- poj 1007 DNA Sorting
- [POJ][1007]DNA Sorting
- POJ 1007 DNA Sorting
- poj 1007 DNA sorting
- 用 Tomcat 和 Eclipse 开发 Web 应用程序
- POJ 1004 Financial Management
- POJ 1005 I Think I Need a Houseboat
- Tomcat全攻略
- POJ 1006 Biorhythms
- POJ 1007 DNA Sorting
- 标签说明
- POJ 1008 Maya Calendar
- 中国剩余定理
- USACO Milking Cows
- 文本文件与二进制文件
- tomcat如何配置环境变量
- USACO Transformations
- 第一次