Connection Status:
Competition Arena > BarongAndRangda
SRM 840 · 2022-10-24 · by misof · Simple Math
Class Name: BarongAndRangda
Return Type: String
Method Name: compare
Arg Types: (int, int, int, int)
Problem Statement

Problem Statement

Barong and Rangda are characters from Balinese mythology. Barong, the king of spirits, represents good, while Rangda, the demon queen, represents evil.

We know that Barong is stronger than Rangda.


While traveling in Bali, we were pondering hypothetical fights between two teams, each consisting of some Barongs and some Rangdas.

Suppose there are two teams:

  • Team 1 consists of B1 Barongs and R1 Rangdas.
  • Team 2 consists of B2 Barongs and R2 Rangdas.

Consider the following statement: "Team 1 is stronger than team 2."

There are three possible scenarios, listed below. Determine which scenario occurs and return the corresponding message. (See Notes below if you need a more formal definition of the problem.)

  • If we can be sure that the statement is correct, return "correct".
  • If we can be sure that the statement is not correct, return "incorrect".
  • In all other cases, return "unknown".

Notes

  • All Barongs on both teams are identical copies of the same Barong and thus they all have the same strength: a positive real number b.
  • The same is true about all the Rangdas: the strength of each Rangda is the same positive real number r.
  • We don't know the exact values of b and r, we only know that b > r.
  • The strength of a team is the sum of the strengths of individuals that form the team.

Constraints

  • B1 will be between 0 and 10^8, inclusive.
  • R1 will be between 0 and 10^8, inclusive.
  • B2 will be between 0 and 10^8, inclusive.
  • R2 will be between 0 and 10^8, inclusive.
Examples
0)
1
0
0
1
Returns: "correct"

Team 1 has one Barong, team 2 has one Rangda. Team 1 is obviously stronger than team 2.

1)
0
1
1
0
Returns: "incorrect"

Team 1 has one Rangda, team 2 has one Barong. The statement "Team 1 is stronger than team 2." is obviously false.

2)
0
0
0
0
Returns: "incorrect"

Both teams are empty, and thus they have the exact same strength. Therefore the statement "Team 1 is stronger than team 2." is false.

3)
4
7
1
1
Returns: "correct"

A team with 4 Barongs and 7 Rangdas is clearly stronger than a team with just one being of each type.

4)
9
0
0
10
Returns: "unknown"

Are 9 Barongs stronger than 10 Rangdas? We don't know: it's possible that they are, but it's also possible that they aren't.

Submissions are judged against all 168 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class BarongAndRangda with a public method string compare(int B1, int R1, int B2, int R2) · 168 test cases · 2 s / 256 MB per case

Submitting as anonymous