Tap here to switch tabs
Problem
Submissions

Problem: Maximum Good People Based on Statements

med
30 min
Try to solve the Maximum Good People Based on Statements problem.

Statement

There are n people, each of whom is either good or bad:

  • A good person always tells the truth.

  • A bad person may tell the truth or lie.

You are given a 00 indexed two dimensional integer array statements of size n $ imes$ n, where statements[i][j] represents the statement made by person i about person j:

  • statements[i][j] == 00 indicates person i states that person j is bad.

  • statements[i][j] == 11 indicates person i states that person j is good.

  • statements[i][j] == 22 indicates person i makes no statement about person j.

Additionally, no person makes a statement about themselves, meaning statements[i][i] == 22 for all i.

Return the maximum number of people who can be good based on the given statements.

Constraints:

  • n == statements.length == statements[i].length

  • 2≤2 \leq n ≤15\leq 15

  • statements[i][j] is either 00, 11, or 22.

  • statements[i][i] == 22

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Good People Based on Statements

med
30 min
Try to solve the Maximum Good People Based on Statements problem.

Statement

There are n people, each of whom is either good or bad:

  • A good person always tells the truth.

  • A bad person may tell the truth or lie.

You are given a 00 indexed two dimensional integer array statements of size n $ imes$ n, where statements[i][j] represents the statement made by person i about person j:

  • statements[i][j] == 00 indicates person i states that person j is bad.

  • statements[i][j] == 11 indicates person i states that person j is good.

  • statements[i][j] == 22 indicates person i makes no statement about person j.

Additionally, no person makes a statement about themselves, meaning statements[i][i] == 22 for all i.

Return the maximum number of people who can be good based on the given statements.

Constraints:

  • n == statements.length == statements[i].length

  • 2≤2 \leq n ≤15\leq 15

  • statements[i][j] is either 00, 11, or 22.

  • statements[i][i] == 22