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

22909번 - Minimum Sort 서브태스크다국어인터랙티브채점 준비 중

시간 제한메모리 제한제출정답맞힌 사람정답 비율
60 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)0000.000%

문제

In this problem, you need to sort a list of N = 100 distinct integers in strictly increasing order. You can rearrange the list by swapping the contents of any two positions (they do not need to be adjacent). Unfortunately, you cannot read those contents directly. You can access information about the list contents by querying the minimum of a range. The minimum query gives you the position of the minimum value over a range of consecutive positions. For example, in the list [51, 33, 100, 11], the minimum over the range between positions 2 and 4, inclusive (1-based), is at position 4 and the minimum between positions 1 and 3 is at position 2.

Queries about the minimum within a range are limited by a coin budget per test case. Larger ranges are cheaper: asking about the position of the minimum between positions i and j (for i < j) costs ⌈108 / (j − i + 1)⌉ coins, where ⌈x⌉ is the smallest integer greater than or equal to x (that is, x rounded up). Swap operations, on the other hand, do not cost any coins.

Write a program that sorts lists of integers using any number of swaps and at most 6 × 108 coins per test case distributed among any number of minimum queries.

입력과 출력

This is an interactive problem.

Initially, the judge will send you a single line containing two integers T and N: the number of test cases and the number of elements to sort within each test case, respectively. The judge has the initial lists preset before it gets any input from your program, and the only changes done to them during the exchanges with your program are the swaps that you request.

Then, you must process T test cases. Each test case consists of a series of exchanges plus an additional line indicating you are done. Each exchange consists of you printing one line and the judge printing one line in response. Your program must print a single line containing one of these options:

  • An uppercase M and two integers i and j with i < j representing a minimum query. The judge responds with a single integer representing the position of the minimum value in the list within 1-based positions i and j, inclusive.
  • An uppercase S and two integers i and j with i < j representing a swap operation. The judge swaps the two elements at 1-based positions i and j and responds with 1.
  • An uppercase D representing that you are done sorting the list. The judge checks the list. It responds with 1 if the list is sorted in strictly increasing order and -1 if it is not.

After the judge responds 1 to a D, it will finish if it was the last test case or it will immediately start waiting for your first command for the next test case. After receiving the judge's response for the T-th case, your program must finish in order to not receive a Time Limit Exceeded error.

If the judge receives an invalidly formatted line or invalid values from your program at any moment, including a minimum operation whose cost would exceed your remaining budget for the test case, the judge will print a single number -1. After the judge prints -1 for any of the reasons explained above, it will not print any further output. If your program continues to wait for the judge after receiving a -1, your program will time out, resulting in a Time Limit Exceeded error. Notice that it is your responsibility to have your program exit in time to receive a Wrong Answer judgment instead of a Time Limit Exceeded error. As usual, if the memory limit is exceeded, or your program gets a runtime error, you will receive the appropriate judgment.

입력

출력

제한

Test Set 1 (15점)

  • T = 100.
  • N = 100.

예제 입력 1

2 4
4
2
1
4
1
1
3
1
3
2
1

예제 출력 1

M 2 4
M 1 3
S 1 4
M 3 4
S 3 4
D
M 1 4
S 1 3
M 3 4
M 2 4
D

힌트

테스팅 툴

출처

Contest > Google > Code Jam > Google Code Jam 2021 > Round 2 A번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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