FNDTWN - Editorial

PROBLEM LINK:

Practice
Contest

Author: Vasu Gamdha

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Isosceles Triangle

PROBLEM:

If the given three sides can form a isosceles triangle, Alice wins. Otherwise, Bob wins.

QUICK EXPLANATION:

  • Check, with the given three sides, if even a triangle is possible or not.
  • If triangle is possible, check whether any two sides are equal.
  • If both conditions are true, Isosceles triangle is possible. Otherwise not.

EXPLANATION:

A triangle having two sides of equal length, is called Isosceles triangle.

Problem does not state, that the triangle is possible. So, we have to check that first.

If sum of the two sides is greater than the third side, triangle can be formed.
Consider a, b and c are the sides given. So, if all below conditions are true, triangle can be formed.

  1. a + b > c
  2. a + c > b
  3. b + c > a

Now, moving to the second part, i.e. check if triangle is isosceles triangle or not.
For that, if any of the below conditions are true,

  1. a == b
  2. b == c
  3. a == c

If Isosceles triangle is possible, Alice wins. Otherwise, Bob wins.

Time Complexity:

TIME: O(1) per test-case

SOLUTIONS:

Setter's Solution
test=int(input())
for _ in range(test):
    a,b,c=map(int,input().split())
    if (a==b or b==c or c==a) and (a+b>c and b+c>a and c+a>b):#Equilateral is also isosceless
        print("Alice")
    else:
        print("Bob")