CF496C Removing Columns
题目描述
给你一个$n$*$m$的小写字符矩阵,你可以选择删除一些列,使得剩下的字符矩阵的每一行的字符串从上到下的字典序非减。
求最少删除多少列
输入格式
第一行输入两个整数n,m
接下来n行每行输入m个字符
输出格式
输出一个整数表示最少删除的列
说明/提示
In the first sample the table is already good.
In the second sample you may remove the first and third column.
In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).
Let strings $ s $ and $ t $ have equal length. Then, $ s $ is lexicographically larger than $ t $ if they are not equal and the character following the largest common prefix of $ s $ and $ t $ (the prefix may be empty) in $ s $ is alphabetically larger than the corresponding character of $ t $ .