| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我也晒下代码,没什么理论,就是靠着理解模拟,16MS#include <iostream>
using namespace std;
char DNA[105][55];
int nixushu[105];
int main()
{ freopen("in.txt","r",stdin);
int n,m,p;
int i,j;
cin>>n>>m;
for(i=0;i<m;i++)
{
nixushu[i]=0;
cin>>DNA[i];
int k;
for(j=0;j<n;j++)
for(k=0;k<j;k++)
if(DNA[i][k]>DNA[i][j])
nixushu[i]++;
}
int h,min=999999999,minx;
p=m;//循环变量P,用于while循环
while(p--)
{
for(h=0;h<m;h++)
{
if(nixushu[h]<min)
{
min=nixushu[h];
minx=h;//记录逆序数最小值下标
}
}
nixushu[minx]=999999999;
min=99999999;
cout<<DNA[minx]<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator