Tally up everyone’s claims. Look at all the people who are claimed to be mafiosos by at least 54 other people. It’s impossible for two of these people to be good, because at most 106 votes are directed at good people. At least one of them must be a mafioso, because at least 194 votes are directed at mafiosos.

If there are at least three people in this group, check it any of them name each other. A good person in the group must name at least one of the others, and the mafiosos in the group can only name a unique person within the group. So if anyone in the group names none of the other people in the group, or if two of more people in the group name the same other person in the group, they must be mafiosos. One of these two possibilities must happen, so we’ve found a mafioso.

If there’s just one person in the 54 vote group, they must be bad.

Otherwise, there are exactly two people who receive at least 54 votes, of whom at least one is bad. If exactly one of them is bad, then the other two bad guys receive at most 53 votes, and the bad guy in the high-vote group receives at least 88 votes. If no one gets at least 88 votes, both people in the high-vote group are bad.

So let’s assume there’s are exactly two people in the high-vote group, both with at least 88 votes. Then there are only 18 other votes for good guys remaining, so anyone with at least 19 votes but less than 53 votes must be bad. But there are at least 94 votes among the other two bad guys, so one of them has at least 47 votes, and that person must be bad. Actually, because neither has guy has over 53 votes, both have at least 19 votes, so both can be identified.

To summarize:

Look at how many people get at least 54 votes. It must be at least 1.

– If it’s exactly one, that person is bad.

– If it’s exactly two, look at how many people get at least 88 votes.

— If it’s none, both people over 54 are bad.

— If it’s one, that person is bad.

— If it’s two, look at the people with at least 19 votes, but less than 88. There are exactly two, and they are both bad.

– If it’s three or more, look at how many people in the high-vote group point at each person in that group.

— If someone is pointed at by multiple people in the high-vote group, that person is good, and everyone else is the high-vote group is bad.

— Otherwise, someone in the high-vote group must point at none of the other people in the group. That person is bad.