#P9187. [USACO23OPEN] Field Day S
[USACO23OPEN] Field Day S
题目描述
Note: The time limit for this problem in Python is 15s. Other languages have the default time limit of 2s.
Each of Farmer John's barns has selected a team of cows to participate in field day. The breed of every cow is either a Guernsey or a Holstein.
The difference between two teams is defined to be the number of positions () at which the breeds of the cows in the th positions differ. For every team from , please compute the maximum difference between team and any other team.
输入格式
The first line contains and .
The next lines each contain a string of length of G
s and H
s. Each line
corresponds to a team.
输出格式
For each team, print the maximum difference.
题目大意
题目描述
提示:本题的 Python 时限为 15s。其它语言默认 2s。
Farmer John 的 个牛棚都会选出包含 只奶牛的队伍去参加户外聚会。所有奶牛的品种都只可能是根西牛(G
)或荷斯坦奶牛(H
)。
我们将两个奶牛队伍中,同一位置对应的两头奶牛品种不同的所有位置 的个数,定义为的两个奶牛队伍的差异。对于编号 的每个奶牛队伍 ,请计算出 和其它所有队伍的差异的最大值。
输入格式
第一行包含两个整数 与 。
接下来 行,每行有一个长度为 的,仅包含字母 G
和 H
的字符串,每行对应一支奶牛队伍。
输出格式
对于每个队伍,输出差异最大值。
说明/提示
第一个和第三个队伍的差异为 。第二个和第三个队伍的差异为 。
。
- 对于测试点 2-5:。
- 对于测试点 6-9:所有答案最少为 。
- 对于测试点 10-20:没有额外条件。
5 3
GHGGH
GHHHH
HGHHG
5
3
5
提示
The first and third teams differ by . The second and third teams differ by .
, .
- Inputs 2-5: .
- Inputs 6-9: All answers are at least .
- Inputs 10-20: No additional constraints.