QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 2048 MB 總分: 100

#2923. 代码猜测

统计

Alice 和 Bob 正在玩一个包含九张牌的桌面游戏。每张牌上都有一个 1 到 9 之间的数字,且每个数字各有一张。洗牌后,Alice 和 Bob 各自抽取两张牌,并查看自己手中的数字,但不向对方透露。随后,Alice 将她的两张牌交给 Bob。Bob 看到了 Alice 的两张牌,并将这四张牌按数字从小到大的顺序排列在桌面上。牌面均朝下放置。

Bob 告诉了 Alice 她那两张牌在桌面上的位置。Alice 的目标是猜出 Bob 手中那两张牌上的数字。Alice 能否唯一确定这两张牌的数字并正确猜出它们?

输入格式

输入的第一行包含两个整数 $p, q$ ($1 \le p < q \le 9$),表示 Alice 手中牌的数字。下一行包含一个由两个 'A' 和两个 'B' 组成的字符串,表示 Alice 和 Bob 的牌在桌面上的位置。保证 Bob 正确地对牌进行了排序,并给出了 Alice 牌的正确位置。

输出格式

如果 Alice 能唯一确定 Bob 手中两张牌的数字,则输出这两个数字,按从小到大的顺序排列在同一行。否则,输出 $-1$。

样例

输入格式 1

6 9
ABBA

输出格式 1

7 8

输入格式 2

2 5
BAAB

输出格式 2

-1

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.