#506
Silver III
Stuck in a Rut
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John has recently expanded the size of his farm, so from the perspective of his cows it is effectively now infinite in size! The cows think of the grazing area of the farm as an infinite 2D grid of square "cells", each filled with delicious grass (think of each cell as a square in an infinite chessboard). Each of Farmer John's NN cows (1N501\le N\le 50) starts out in a different cell; some start facing north, and some start facing east.

Every hour, every cow either

Stops if the grass in her current cell was already eaten by another cow.Eats all the grass in her current cell and moves one cell forward according to the direction she faces.

Over time, each cow therefore leaves a barren "rut" of empty cells behind her.

If two cows move onto the same grassy cell in the same move, they share the cell and continue moving in their respective directions in the next hour.

Please determine the amount of grass eaten by each cow. Some cows never stop, and therefore eat an infinite amount of grass.

입력

The first line of input contains NN. Each of the next NN lines describes the starting location of a cow, in terms of a character that is either N (for north-facing) or E (for east-facing) and two nonnegative integers xx and yy (0x1090\le x\le 10^9, 0y1090\le y\le 10^9) giving the coordinates of a cell. All xx-coordinates are distinct from each-other, and similarly for the yy-coordinates.

출력

Print NN lines of output. Line ii in the output should describe the number of cells worth of grass that the iith cow in the input eats. If a cow eats an infinite amount of grass, output "Infinity" for that cow.

예제 입력 1

6
E 3 5
N 5 3
E 4 6
E 10 4
N 11 2
N 8 1

예제 출력 1

5
3
Infinity
Infinity
2
5

점수

In test cases 2-5, all coordinates are at most 100100.In test cases 6-10, there are no additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Silver III1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.