#P1892. [BalticOI 2003] 团伙
[BalticOI 2003] 团伙
Description
There are people, and between any two people there are two kinds of relations: friend and enemy. We know:
- A person's friend's friend is also a friend.
- A person's enemy's enemy is a friend.
We want to form groups. Two people are in the same group if and only if they are friends. Find the maximum possible number of groups among these people.
Input Format
The first line contains an integer , the number of people.
The second line contains an integer , meaning that relations follow.
Each of the next lines contains a character and two integers , representing the type of relation (friend or enemy), the first person, and the second person among the two who have a relation. The character has two possibilities:
- If is
F, then and are friends. - If is
E, then and are enemies.
Output Format
Output a single integer on one line: the maximum number of groups.
6
4
E 1 4
F 3 5
F 4 6
E 1 2
3
Hint
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号