A14531 | One-Four Overload
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice has an empty grid with $n$ rows and $m$ 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 $1$ or $4$ ;
- 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 $0$ );
- every marked cell contains a multiple of $5$ .
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 wants to fill each cell with a number such that the following statements are true:
- every unmarked cell contains either the number $1$ or $4$ ;
- 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 $0$ );
- every marked cell contains a multiple of $5$ .
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.
输入格式
The first line of input contains two integers $n$ and $m$ ( $1 \leq n, m \leq 500$ ) — the number of rows and the number of columns in the grid, respectively.
Then $n$ lines follow, each containing $m$ 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.
Then $n$ lines follow, each containing $m$ 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.
输出格式
Output "'NO" if no suitable grid exists. Otherwise, output "'YES"'. Then output $n$ lines of $m$ space-separated integers — the integers in the grid.
输入输出样例
输入 #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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted