QOJ.ac

QOJ

Límite de tiempo: 6 s Límite de memoria: 512 MB Puntuación total: 100

#4757. 寻找金库

Estadísticas

Khodislav 正在玩他最喜欢的 Roguelike 游戏。游戏的每一层都是一个矩形网格,每个单元格要么是空的,要么包含一堵墙。在玩家靠近某个单元格之前,无法得知其中是什么。

宝库房间非常有价值,它们可能被隐藏起来,使得玩家无法通过常规手段到达。为了进入这样的房间,玩家必须施放一个能揭示该层部分单元格的法术,以及传送法术。幸运的是,游戏的维基页面包含了一个矩形的宝库布局。宝库可以位于游戏层中的任何位置,但其方向必须与维基上的布局完全匹配。

Khodislav 已经解锁了该层的一部分,并对宝库可能的位置感到好奇。请找出所有与已知信息不矛盾的宝库左上角可能的位置。注意,宝库必须完全位于游戏层内。

输入格式

第一行包含四个整数:$R, C$ —— 分别为游戏层的行数和列数,以及 $A, B$ —— 分别为宝库布局的行数和列数 ($1 \le R, C \le 2000, 1 \le A \le R, 1 \le B \le C$)。

接下来是游戏层的地图:共 $R$ 行,每行包含 $C$ 个字符。对于每个单元格,提供以下三种字符之一:

  • ‘#’ (ASCII 35) —— 该单元格是墙,
  • ‘.’ (ASCII 46) —— 该单元格是空的,
  • ‘_’ (ASCII 95) —— 该单元格的内容未知。

接下来的 $A$ 行描述宝库布局,每行 $B$ 个字符。对于每个单元格,提供以下三种字符之一:

  • ‘#’ (ASCII 35) —— 该单元格必须是墙,
  • ‘.’ (ASCII 46) —— 该单元格必须是空的,
  • ‘_’ (ASCII 95) —— 该单元格可以是任何内容。

输出格式

在第一行,输出一个整数 $K$ —— 宝库可能的位置数量 ($0 \le K \le (R - A + 1) \cdot (C - B + 1)$)。在接下来的 $K$ 行中,每行输出一个位置。每个位置由两个空格分隔的整数 $u$ 和 $v$ 定义 —— 表示宝库布局左上角单元格在游戏层中的行索引和列索引 ($1 \le u \le R - A + 1, 1 \le v \le C - B + 1$)。

位置必须按 $u$ 的升序排列,若 $u$ 相等,则按 $v$ 的升序排列。

样例

样例输入 1

12 12 6 6
_______###__
______##.##_
______#...#_
___#####.##_
_###_..###.#
##.##......#
#...#.####_#
##.##.._____
_###_.______
_____.______
_____.______
_____.______
__###_
_##.##
_#...#
_##.##
__###_
______

样例输出 1

2
1 6
7 7

样例输入 2

4 5 2 3
_____
_._##
_._._
__#__
_##
##.

样例输出 2

0

说明

第一个样例的示意图如下:

图中展示了宝库的两个可能位置,用粗红框标出。在底部的位置中,大部分单元格的内容是未知的:只有两个单元格在游戏地图和宝库布局上是精确定义的。左侧可以看到一个非常类似于宝库的结构。然而,如果不向左增加一列,它无法完全放入游戏地图中。

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.