RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
R03607

S3. Swipe

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Swipe is a new mobile game that has recently exploded in popularity.
In each level of Swipe, you are given \(2\) rows of integers that can be
represented as arrays \(A\) and \(B\) of size \(N\). The objective of Swipe is to beat each
level by turning array \(A\) into array
\(B\).

There are two swipe operations you can perform on array \(A\).

  • Swipe right: Select the subarray \([\ell,r]\) and set \(A_i = A_\ell\) for all \(\ell \le i \le r\).

  • Swipe left: Select the subarray \([\ell,r]\) and set \(A_i = A_r\) for all \(\ell \le i \le r\).

For example, starting with array \(A = [0,1,2,3,4,5]\), if we swipe right on \([2,4]\), we would obtain the array \([0,1,2,2,2,5]\). If instead, we started
with the same array \(A\), and swiped
left on \([3,5]\), we would obtain the
array \([0,1,2,5,5,5]\). Note that
these arrays are \(0\)-indexed.

Unfortunately, the game is bugged and contains levels that are
impossible to beat. Determine if it is possible to transform array \(A\) into array \(B\). If it is possible, determine a
sequence of swipe operations that transforms array \(A\) into array \(B\).

제약

\(\ell \le i \le r\)

입력 형식

The first line of input will consist of one positive integer \(N\), representing the length of each of the
two arrays of integers.

The second line of input contains \(N\) space separated integers contained in
array \(A\).

The third line of input contains \(N\) space separated integers contained in
array \(B\).

Note that for a subtask worth \(M\)
marks, you will receive \(\left\lfloor \frac{M}{2} \right\rfloor\) marks for a solution that only
correctly outputs the first line of output.

출력 형식

The first line of output will contain YES if there is a
sequence of swipes that can transform array \(A\) into array \(B\); otherwise, the first line of output
will contain NO.

If the first line of output is YES, the next line
contains a non-negative integer \(K\)
(\(K \leq N\)), indicating the number
of swipes.

Each of the next \(K\) lines contain
three space-separated values: \(D_j\),
\(\ell_j\), and \(r_j\). The value \(D_j\) will be either R or
L, indicating that the \(j\)th swipe is either a right or left
swipe, respectively. The values \(\ell_j\) and \(r_j\) indicate the left-end and right-end
of the swipe where \(0 \le \ell_j \le r_j < N\).

서브태스크
서브태스크점수설명

1

13점

\(N=2\)\(1 \le A_i,B_i \leq 3\)

2

27점

\(1 \le N \le 8\)\(1 \le A_i,B_i \leq 8\)

3

26점

\(1 \le N \le 500\)\(1 \le A_i,B_i \leq 3000\)

4

34점

\(1 \le N \le 300\,000\)\(1 \le A_i,B_i \leq 300\,000\)

예제 1
입력
3
3 1 2
3 1 1
출력
YES
1
R 1 2
예제 2
입력
4
1 2 4 3
1 4 2 3
출력
NO
예제 3
입력
4
2 1 4 3
2 1 4 3
출력
YES
0
문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2024 Senior

평가 및 의견

S3. Swipe

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

S3. Swipe

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8