아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

First Solved, Last Coded

시간 제한2초메모리 제한1024 MB

요약
Sol이 제시한 순서로 문제를 스택에 넣어 Codie가 원하는 순서로 꺼낼 수 있는지 판정하고, 가능하면 유효한 S와 C의 나열을 출력한다.
난이도

보통10점 중 4점

유형
스택, 시뮬레이션, 그리디
정답자
아직 제출이 없습니다

문제

In ICPC, teamwork is everything. That's why everyone on your team has a well-defined role: Sol the Solver can solve any problem in the problem set, Codie the Coder can implement any solution that Sol comes up with, and you... are the glue that holds everything together. Sol and Codie are very picky about the order of problems they would solve/code, and your job is to satisfy their preferences.

There will be nn problems in the upcoming contest, and you know the general topic of each problem: greedy, geometry, graphs, etc. For simplicity, we will represent each topic with an integer from 11 to nn. These integers don't have to be distinct, that is, multiple problems in the contest can have the same topic.

Sol wants to solve problems in a specific order of topics: first, the problem with the topic a_1a\_1, after that, the problem with the topic a_2a\_2, \ldots, and finally, the problem with the topic a_na\_n. Codie also has a preference list: b_1,b_2,…,b_nb\_1, b\_2, \ldots, b\_n, only willing to code problems in that order of topics.

Your job during the contest will be to take solution sheets from Sol and hand them to Codie in the correct order. As your team only has one table to work with, you don't have enough space to arrange all the solutions neatly. Thus, you came up with the following workflow: you will ask Sol for solutions (who will hand them to you in order a_1,a_2,…,a_na\_1, a\_2, \ldots, a\_n), store them in a stack on your part of the table, and hand them to Codie to code (in order b_1,b_2,…,b_nb\_1, b\_2, \ldots, b\_n).

More formally, at any moment during the contest, you have (at most) two actions you can make:

  • If there are still any unsolved problems remaining, ask Sol for another solution and put it on top of your stack of solution sheets. This action is denoted by the character 'S'.
  • If your stack is not empty, take the solution sheet from the top of your stack and give it to Codie to implement. This action is denoted by the character 'C'.

For the given lists of Sol's and Codie's preferences, find a sequence of actions that ensures that all problems are solved and coded in the correct order. Consider all solving and coding times insignificant --- managing solution sheets is a much harder and more important job anyway.

입력

The first line contains a single integer nn, denoting the number of problems in the contest (1≤n≤1001 \le n \le 100).

The second line contains nn integers a_1,a_2,…,a_na\_1, a\_2, \ldots, a\_n, denoting Sol's preferred order of topics (1≤a_i≤n1 \le a\_i \le n).

The third line contains nn integers b_1,b_2,…,b_nb\_1, b\_2, \ldots, b\_n, denoting Codie's preferred order of topics (1≤b_i≤n1 \le b\_i \le n).

The given lists are equal as multisets: every integer occurs the same number of times in AA and in BB.

출력

If your task is impossible, print "NO". Otherwise, print "YES" on the first line, followed by the sequence of actions on the second line: a string consisting of 2n2n characters 'S' or 'C' (nn of each), describing your actions in order.

You are not allowed to ask Sol for more solutions if all nn problems have already been solved, or give Codie a solution with the wrong topic. If there are multiple answers, print any of them.

예제2

  1. 예제 1

    입력
    4
    4 1 2 2
    1 2 4 2
    
    예상 출력
    YES
    SSCSCCSC
    
  2. 예제 2

    입력
    3
    2 3 1
    1 2 3
    
    예상 출력
    NO