Problem 1198 --DNA Sorting

1198: DNA Sorting

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $2269$ 正确数量 $1440$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 字符串 排序
One measure of "unsortedness" in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC'', this measure is 5, since D is greater than four letters to its right and E is greater than one letter to its right. This measure is called the number of inversions in the sequence. The sequence ``AACEDGG'' has only one inversion (E and D)---it is nearly sorted---while the sequence ``ZWQM'' has 6 inversions (it is as unsorted as can be---exactly the reverse of sorted).

You are responsible for cataloguing a sequence of DNA strings (sequences containing only the four letters A, C, G, and T). However, you want to catalog them, not in alphabetical order, but rather in order of ``sortedness'', from ``most sorted'' to ``least sorted''. All the strings are of the same length.
The first line contains two integers: a positive integer n (0 < n <= 50) giving the length of the strings; and a positive integer m (0 < m <= 100) giving the number of strings. These are followed by m lines, each containing a string of length n.
Output the list of input strings, arranged from ``most sorted'' to ``least sorted''. Since two strings can be equally sorted, then output them according to the orginal order.
10 6
AACATGAAGG
TTTTGGCCAA
TTTGGCCAAA
GATCAGATTT
CCCGGGGGGA
ATCGATGCAT
CCCGGGGGGA
AACATGAAGG
GATCAGATTT
ATCGATGCAT
TTTTGGCCAA
TTTGGCCAAA

推荐代码 查看1198 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] 曾国强 868799 2022-06-21 11:44:58
内存最少[$1096 $KB] crush 721104 2021-03-18 17:29:23
第一AC 计爱玲 75946 2017-04-06 19:44:13
第一挑战 邓炜@信息与计算科学142 3168 2016-05-20 12:29:56

赛题来源/所属竞赛 icpc1st@ahstu N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛
1797 2023-2024-2学期<计算机专业竞赛实训> 第1周练习:STL基础和高精度计算【22计算机】 2024-02-26 00:00:00 请登录
1760 汉云智数2023安工大《Java编程实训》Java基础和字符串 2023-06-30 09:00:00 请登录
1737 2022-2023-2学期<计算机专业竞赛实训> 第3周练习:STL基础:string/高精度计算【21计算机12345】 2023-03-07 07:00:00 请登录
1708 2022安科《Java编程实训(设计模式)》Java基础和字符串【20计算机12345】 2022-09-21 07:00:00 请登录
1701 汉云智数2022安工大《Java编程实训(安卓方向)》Java基础和字符串 2022-06-20 12:00:00 请登录