package Test;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class T1006 {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n,m;
n = input.nextInt();
m = input.nextInt();
DNA[] dna = new DNA[m];
int countA,countT,countC,countG;
for(int i=0;i<m;++i){
dna[i] = new DNA();
dna[i].s = input.next();
}
Map<Integer, String> map = new TreeMap<Integer, String>();
for(int i=0;i<m;++i){
countA=0;
countT=0;
countC=0;
countG=0;
dna[i].count=0;
for(int j=n-1;j>=0;--j){
if(dna[i].s.charAt(j)=='A'){
countA++;
}
else if(dna[i].s.charAt(j)=='C'){
countC++;
dna[i].count+=countA;
}
else if(dna[i].s.charAt(j)=='G'){
countG++;
dna[i].count+=countA+countT;
}
else{
countT++;
dna[i].count+=countA+countC+countG;
}
}
map.put(dna[i].count, dna[i].s);
}
for (String x : map.values()) {
System.out.println(x);
}
// for(int i=0;i<m;++i){
// System.out.println(dna[i].count);
// }
// MyComporator cmp = new MyComporator();
// Arrays.sort(dna,0,m,cmp);
// for(int i=0;i<m;++i){
// System.out.println(dna[i].count);
// }
// for(int i=0;i<m;++i){
// System.out.println(dna[i].s);
// }
}
}
class DNA
{
String s;
int count;
DNA(){
s = new String();
}
}
class MyComporator implements Comparator{
@Override
public int compare(Object arg0, Object arg1) {
// TODO Auto-generated method stub
DNA d1 = (DNA)arg0;
DNA d2 = (DNA)arg1;
if(d1.count>d2.count)
return 0;
else
return 0;
}
}
Java 集合系列12之 TreeMap详细介绍(源码解析)和使用示例
POJ1007
最新推荐文章于 2021-02-23 15:33:11 发布