Logo
(追記) (追記ここまで)

17045번 - Slagalica 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB73250.000%

문제

Since he learnt how to solve the Rubik's cube, Jurica has also been interested in other puzzles of this kind and he recently created an enigmatic toy himself. We can imagine Jurica’s puzzle as a triangular net in the form of a parallelogram whose nodes are arranged in N rows and M columns. The rows are labeled from 1 to N from the bottom up, and the columns are labeled 1 to M from left to right. Each node is denoted by coordinates (x, y), where x is the row and y is the column. Each node has a unique integer value between 1 and N·M written in it, and the puzzle is considered solved when the first row contains numbers from 1 to M ordered from left to right, the second row contains numbers from M+1 to 2M in the same order, etc. The picture below shows a solved puzzle of 3 rows and 4 columns.

The layout of the puzzle can be changed in two ways:

  1. By selecting the unit sized rhombus whose nodes are determined by the coordinates (x, y), (x+1, y), (x+1, y+1) and (x, y+1), and rotating the node values in the clockwise direction.
  1. By selecting a unit sized equilateral triangle whose nodes are determined by the coordinates (x, y), (x+1, y) and (x, y+1) and rotating of the node values in the clockwise direction.

On one boring day, Jurica scrambled the puzzle, writing down the moves he had made on a piece of paper. This sequence of moves he called a mega-move, and explained the application of mega-move as the sequential application of the moves written on the paper. After that, he has repeatedly made the same mega-move several times. He noticed an unusual regularity soon. Starting from a solved puzzle, after exactly K mega-moves, the puzzle will again be solved (the first time since applying the mega-moves).

For given integers N, M and K, determine if there is a mega-move that will allow Jurica to solve the puzzle after exactly K repetition of that mega-move, and if so, print that sequence of moves. Note: The solution is not necessarily unique and does not have to be optimal in the number of the moves, but the number of moves is limited (see section Input).

입력

The first line contains three integers N, M (2 ≤ N, M ≤ 100) and K (2 ≤ K ≤ 1012), the numbers from the task description.

출력

If there is not such a mega-move that meet the conditions from the task, print -1 in the only line. Otherwise, print the number of moves B (1 ≤ B ≤ 500 000) in the first line and in the following B lines one move in the following form:

  • "R x y" (without the quotation marks) if it is a rotation of a rhombus (operation 1), or
  • "T x y" (without the quotation marks) if it is a rotation of an equilateral triangle (operation 2),

whereas the coordinate (x, y) represents the bottom left node of the rhombus or the triangle and it holds that 1 ≤ x < N and 1 ≤ y < M.

제한

예제 입력 1

2 3 2

예제 출력 1

5
R 1 1
R 1 1
T 1 1
T 1 1
T 1 1

예제 입력 2

3 3 12

예제 출력 2

3
R 1 1
T 2 2
T 2 1

예제 입력 3

5 4 116

예제 출력 3

-1

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2018/2019 > Contest #4 4번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /