QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20979. 陷入辙迹

Statistics

Farmer John 最近扩大了农场,在奶牛眼中,现在它几乎无限大!奶牛将放牧区看成由正方形“格子”组成的无限二维网格,每格都长满美味的草(可以将每格想成无限棋盘上的一格)。他的 $N$ 头奶牛($1\le N\le 50$)各从一个不同格子出发,有的朝北,有的朝东。

每小时,每头奶牛进行以下两种行为之一:

  • 如果当前格子的草已经被另一头奶牛吃掉,就停下。
  • 吃掉当前格子的所有草,并沿面对的方向前进一格。

因此,随着时间推移,每头奶牛身后都会留下由空格子组成的荒芜“辙迹”。

如果两头奶牛在同一次移动中进入同一个有草的格子,它们共享该格,并在下一小时继续沿各自的方向移动。

请确定每头奶牛吃掉的草量。有些奶牛永不停下,因此会吃掉无限多的草。

输入格式

输入的第一行包含 $N$。接下来的 $N$ 行各描述一头奶牛的起始位置:一个字符 N(朝北)或 E(朝东),以及两个给出格子坐标的非负整数 $x$ 和 $y$($0\le x\le 10^9$,$0\le y\le 10^9$)。所有 $x$ 坐标互不相同,所有 $y$ 坐标也互不相同。

为明确方向和坐标,如果奶牛在格子 $(x,y)$ 并向北移动,就到达 $(x,y+1)$。如果改为向东移动,则到达 $(x+1, y)$。

输出格式

输出 $N$ 行。第 $i$ 行表示输入中第 $i$ 头奶牛吃掉了多少格的草。如果一头奶牛吃掉无限多的草,为它输出 Infinity。

样例

输入格式 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

子任务

  • 测试点 $2$ 至 $5$ 的所有坐标至多为 $100$。
  • 测试点 $6$ 至 $10$ 没有额外限制。

题目作者:Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.