#P3153. [CQOI2009] 跳舞
[CQOI2009] 跳舞
Description
There are boys and girls at a party.
At the start of each song, all boys and girls are paired into exactly couples to dance ballroom. No boy ever dances two (or more) songs with the same girl.
Some boy–girl pairs mutually like each other, while others mutually do not; there are no "one-way likes." Each boy is willing to dance with at most girls he does not like, and each girl is willing to dance with at most boys she does not like.
Given the mutual-like information for every boy–girl pair, what is the maximum number of songs the party can have?
Input Format
The first line contains two integers and .
Each of the next lines contains characters, and each character is either Y or N. The -th character on line is Y if and only if boy and girl mutually like each other.
Output Format
Output a single integer on one line, representing the maximum number of songs.
3 0
YYY
YYY
YYY
3
Hint
Constraints
- For of the testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号