問題一覧 > 通常問題

No.717 Commitment to Fashion

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 324
作問者 : gotutiyan / テスター : ciel
お気に入りにしたユーザー ProblemId : 2005 / 自分の提出
問題文最終更新日: 2026-06-26 06:06:33
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 196 (順位表) の他の問題:

Problem Statement

Mr. A owns $N$ tops and $M$ bottoms, and each is either plain or patterned. Being a careless person, he throws away any piece of clothing once he has worn it.
However, he is very particular about fashion, and he will only wear clothes if the top and bottom are both plain or both patterned.
Given the integers $N$,$M$ and the strings $S$,$T$ describing the clothes he owns, output the number of days he can wear clothes.

Input

N M
S
T

He owns $N$ tops, whose patterns are given by the string $S$. Similarly, he owns $M$ bottoms, whose patterns are given by the string $T$. In the strings $S$,$T$, "A" denotes plain and "B" denotes patterned.
$1 \le N,M \le 10000$
$|S|=N$
$|T|=M$

Output

Output the number of days he can wear clothes. Print a newline at the end.

Sample

Sample 1
Input
5 5
AABAB
BAABB
Output
4

He can dress in patterned top and bottom for 2 days and in plain top and bottom for 2 days, but on the 5th day, what remains is a plain top and a patterned bottom, so he cannot dress.

Sample 2
Input
5 5
AAAAA
BBBBB
Output
0

No matter what he does, he cannot wear a top and bottom of the same type.

Sample 3
Input
10 8
BBBAABABBB
BABABABA
Output
7

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。