CF269E.String Theory

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The first line of input contains two space-separated integers numbers nn and mm ( 1<=n,m<=1051<=n,m<=10^{5} ), the height and width of the harp in units. Each of the following n+mn+m lines contains 4 space-separated tokens, describing a single string: two symbols aia_{i} , bib_{i} and two integer numbers pip_{i} , qiq_{i} . The pair aia_{i} , pip_{i} describes the first pin, and the pair bib_{i} , qiq_{i} describes the second pin of the string;

A pair ss , xx describes the position of a single pin in a following way:

  1. ss 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. xx 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 nn space-separated integers — the old numbers of rows now placed from top to bottom in the fixed harp. On the second line, output mm 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).

输出格式

输入输出样例

  • 输入#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
    
首页