Distance Duel

View as PDF

Submit solution

Points: 100
Time limit: 2.0s
Memory limit: 977M

Author:
Problem type

Alice and Bob want to go on an adventure. Every day for n days, they each move in a compass direction by a certain number of kilometres. Your task is to determine who is further from where they started after n days of movement.

Input Format

The first line contains an integer n, the number of days.

The next n lines each contain two strings for Alice and Bob respectively, each with a direction (one of "N", "S", "E", "W") followed by an integer k, the distance in kilometres.

Output Format

Print "Alice" if Alice is further from the origin, "Bob" if Bob is further, or "Tie" if they are equidistant from the origin.

Constraints

  • 1 \leq n \leq 10^5
  • 0 \leq k \leq 10^5

Example 1

Input
3
W5 E4
S7 S2
E5 N5
Output
Alice

Alice moves 5km west, 7km south and 5km east, so she ends up 7km from the origin. Bob moves 4km east, 2km south and 5km north, so he ends up 5km from the origin.

Example 2

Input
5
N8 S0
E3 W7
S12 W4
E14 N2
N2 W6
Output
Tie

Comments


  • 0
    ski  commented on Aug. 24, 2024, 11:13 a.m.

    easy porblem


    • 0
      ski  commented on Aug. 24, 2024, 11:13 a.m.

      problem