A8965 | String Theory
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The first line of input contains two space-separated integers numbers $n$ and $m$ ( $1<=n,m<=10^{5}$ ), the height and width of the harp in units. Each of the following $n+m$ lines contains 4 space-separated tokens, describing a single string: two symbols $a_{i}$ , $b_{i}$ and two integer numbers $p_{i}$ , $q_{i}$ . The pair $a_{i}$ , $p_{i}$ describes the first pin, and the pair $b_{i}$ , $q_{i}$ describes the second pin of the string;
A pair $s$ , $x$ describes the position of a single pin in a following way:
1. $s$ is equal to one of the symbols "L", "T", "R" or "B" (without quotes), which means that the pin is positioned on the left, top, right or bottom side of the harp accordingly;
2. $x$ is equal to the number of the row, if the pin is on the left or right border of the harp, and to the number of the column, if the pin is on the top or bottom border of the harp.
It is guaranteed that no two different strings are connected to the same pin.
A pair $s$ , $x$ describes the position of a single pin in a following way:
1. $s$ is equal to one of the symbols "L", "T", "R" or "B" (without quotes), which means that the pin is positioned on the left, top, right or bottom side of the harp accordingly;
2. $x$ is equal to the number of the row, if the pin is on the left or right border of the harp, and to the number of the column, if the pin is on the top or bottom border of the harp.
It is guaranteed that no two different strings are connected to the same pin.
输入格式
If it is possible to rearrange the rows and columns to fix the harp, on the first line output $n$ space-separated integers — the old numbers of rows now placed from top to bottom in the fixed harp. On the second line, output $m$ space-separated integers — the old numbers of columns now placed from left to right in the fixed harp.
If it is impossible to rearrange the rows and columns to fix the harp, output "No solution" (without quotes).
If it is impossible to rearrange the rows and columns to fix the harp, output "No solution" (without quotes).
输出格式
无
输入输出样例
输入 #1
3 4 L T 1 3 L B 2 2 L B 3 3 T R 1 2 T B 2 1 T R 4 1 B R 4 3
输出 #1
1 2 3 3 2 1 4
输入 #2
3 3 L T 1 1 T R 3 1 R B 3 3 B L 1 3 L R 2 2 T B 2 2
输出 #2
No solution
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted