A1181 | [COCI-2008_2009-regional]#1 CIJEVI
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
To help design the new gas pipeline which will be used to deliver Russian gas to Croatia, Zagreb and Moscow are using the computer game Pipe Mania. In the game, Europe is divided into R rows and C columns. Each cell can be empty or contain one of the seven basic pipeline building blocks:
Gas flows from Moscow to Zagreb. Gas can flow in either direction through the building blocks.
Block '+' is special in that gas must flow in two directions (one vertical, one horizontal), as in the following example:
Work on the new pipeline had already started when it was found that malicious hackers got hold of the plan and erased exactly one building block from the plan i.e. replaced it with an empty cell.
Write a program that determines where the block was erased from and what type it was.
Gas flows from Moscow to Zagreb. Gas can flow in either direction through the building blocks.
Block '+' is special in that gas must flow in two directions (one vertical, one horizontal), as in the following example:
Work on the new pipeline had already started when it was found that malicious hackers got hold of the plan and erased exactly one building block from the plan i.e. replaced it with an empty cell.
Write a program that determines where the block was erased from and what type it was.
输入格式
The first line contains two integers R and C, the dimensions of Europe (1 ≤ R, C ≤ 25).
The following R lines contain the plan, each consisting of exactly C characters. The characters are:
• Period ('.'), representing an empty cell;
• The characters '|' (ASCII 124), '-', '+', '1', '2', '3', '4', representing the building block types;
• The letters 'M' and 'Z', representing Moscow and Zagreb. Each of these will appear exactly once in the plan.
The flow of gas will be uniquely determined in the input; exactly one building block will be adjacent to each of Moscow and Zagreb. Additionally, the plan will not have redundant blocks i.e. all blocks in the plan must be used after the missing block is added.
The input will be such that a solution will exist and it will be unique.
The following R lines contain the plan, each consisting of exactly C characters. The characters are:
• Period ('.'), representing an empty cell;
• The characters '|' (ASCII 124), '-', '+', '1', '2', '3', '4', representing the building block types;
• The letters 'M' and 'Z', representing Moscow and Zagreb. Each of these will appear exactly once in the plan.
The flow of gas will be uniquely determined in the input; exactly one building block will be adjacent to each of Moscow and Zagreb. Additionally, the plan will not have redundant blocks i.e. all blocks in the plan must be used after the missing block is added.
The input will be such that a solution will exist and it will be unique.
输出格式
Output the row and column of the erased block, and the type of the block (one of the seven characters as in the input).
输入输出样例
输入 #1
3 7 ....... .M-.-Z. .......
输出 #1
2 4 -
输入 #2
3 5 ..1-M 1-+.. Z.23.
输出 #2
2 4 4
输入 #3
6 10 Z.1----4.. |.|....|.. |..14..M.. 2-+++4.... ..2323.... ..........
输出 #3
3 3 |
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted