QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 2048 MB 총점: 100

#15874. 电子游戏

통계

Alice、Bob 和 Charlie 共享了一批电子游戏卡带。这样,他们中只需要有一个人拥有某款游戏,所有人就都能玩到它。目前最受欢迎的游戏是一款钓鱼游戏(fishing)、一款高尔夫游戏(golf)和一款冰球游戏(hockey)。

最初,Alice 拥有钓鱼游戏,Bob 拥有高尔夫游戏,Charlie 拥有冰球游戏。随着时间的推移,这些游戏在他们之间传阅,因此很难追踪目前谁手上有哪款游戏。

给定一系列请求,表示某个朋友想玩某款特定的游戏,请确定他们需要向谁借这款游戏。

输入格式

输入的第一行包含一个整数 $N$ ($1 \le N \le 100$),表示请求的数量。

接下来的 $N$ 行描述了这些请求,其中第 $i$ 行包含文本 ai wants to play bi,其中 $a_i$ 是 alicebobcharlie 之一,而 $b_i$ 是 fishinggolfhockey 之一。

在第 $i$ 个请求之后,朋友 $a_i$ 现在拥有了游戏 $b_i$。

输出格式

对于每个请求 $i$,输出单行,包含以下信息之一:

  • 如果 $a_i$ 已经拥有游戏 $b_i$,则输出 ai already has bi(不含引号)。
  • 如果 $a_i$ 之前没有拥有 $b_i$,则输出 ai borrows bi from ci(同样不含引号),其中 $c_i$ 是此时拥有游戏 $b_i$ 的朋友的名字。

样例

样例输入 1

4
alice wants to play golf
bob wants to play golf
charlie wants to play hockey
charlie wants to play fishing

样例输出 1

alice borrows golf from bob
bob borrows golf from alice
charlie already has hockey
charlie borrows fishing from alice

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.