CF1567F.One-Four Overload

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice has an empty grid with nn rows and mm columns. Some of the cells are marked, and no marked cells are adjacent to the edge of the grid. (Two squares are adjacent if they share a side.)

Alice wants to fill each cell with a number such that the following statements are true:

  • every unmarked cell contains either the number 11 or 44;
  • every marked cell contains the sum of the numbers in all unmarked cells adjacent to it (if a marked cell is not adjacent to any unmarked cell, this sum is 00);
  • every marked cell contains a multiple of 55.

Alice couldn't figure it out, so she asks Bob to help her. Help Bob find any such grid, or state that no such grid exists.

Alice 有一个 nn 行 mm 列的空网格。其中一些格子被标记,且所有被标记的格子均不与网格边界相邻(两个格子相邻当且仅当它们有一条公共边)。

Alice 希望为每个格子填入一个数字,使得以下条件全部成立:

  • 每个未被标记的格子中填入的数字为 11 或 44;
  • 每个被标记的格子中填入的数字等于其所有相邻的未被标记格子中的数字之和(若某个被标记的格子不与任何未被标记格子相邻,则该和为 00);
  • 每个被标记的格子中填入的数字是 55 的倍数。

Alice 无法解决这个问题,于是向 Bob 寻求帮助。请帮助 Bob 找出任意一种满足上述条件的填数方案,或说明这样的方案不存在。

输入格式

The first line of input contains two integers nn and mm (1≤n,m≤5001 \leq n, m \leq 500) — the number of rows and the number of columns in the grid, respectively.

Then nn lines follow, each containing mm characters. Each of these characters is either '.' or 'X' — an unmarked and a marked cell, respectively. No marked cells are adjacent to the edge of the grid.

输入的第一行包含两个整数 nn 和 mm(1≤n,m≤5001 \leq n, m \leq 500),分别表示网格的行数和列数。

接下来是 nn 行,每行包含 mm 个字符。每个字符要么是 '.',要么是 'X',分别表示未标记的单元格和已标记的单元格。所有已标记的单元格均不与网格边界相邻。

输出格式

Output "'NO" if no suitable grid exists. Otherwise, output "'YES"'. Then output nn lines of mm space-separated integers — the integers in the grid.

如果不存在合适的网格,输出 "NO"。否则,输出 "YES"。然后输出 nn 行,每行包含 mm 个用空格分隔的整数——即网格中的整数。

输入输出样例

  • 输入#1

    5 5
    .....
    .XXX.
    .X.X.
    .XXX.
    .....

    输出#1

    YES
    4 1 4 4 1
    4 5 5 5 1
    4 5 1 5 4
    1 5 5 5 4
    1 4 4 1 4
  • 输入#2

    5 5
    .....
    .XXX.
    .XXX.
    .XXX.
    .....

    输出#2

    NO
  • 输入#3

    3 2
    ..
    ..
    ..

    输出#3

    YES
    4 1
    4 1
    1 4
  • 输入#4

    9 9
    .........
    .XXXXX.X.
    .X...X...
    .X.XXXXX.
    .X.X.X.X.
    .X.XXX.X.
    .X.....X.
    .XXXXXXX.
    .........

    输出#4

    YES
    4 4 4 1 4 1 4 1 4
    1 5 5 5 5 5 4 10 1
    4 5 1 4 1 5 4 4 4
    4 5 1 5 5 0 5 5 1
    4 5 1 5 4 5 1 5 4
    4 5 1 5 5 5 4 5 1
    1 5 4 4 1 1 4 5 1
    4 5 5 5 5 5 5 5 4
    1 1 1 1 4 4 1 1 4

说明/提示

It can be shown that no such grid exists for the second test.

可以证明,第二个测试用例不存在这样的网格。

输入解题思路,AI测评打分。不知道怎么写?

首页