Lazy Sorting | 프로그래밍의 벗 PivotOJ
PivotOJ

Lazy Sorting

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2021-22 openBOJ 29862

문제

Teacher Laur organized a programming contest for his NN students and now wants to award them prizes according to their results. The prizes were lined up on a shelf in correct order, but then Toots toppled the shelf with his horseplay. As the prizes are in identical boxes, the teacher put them back on the shelf in a random order.

The prizes have different weights and the teacher has balance scales that he can use to compare two boxes and find out which is intended for the student with the better result. However, each weighing takes time and the first MM students have already lined up behind his door to receive their prizes...

To minimize the total time that students spend waiting for their prizes, the teacher wants to give each student their prize with as few weighings as possible. Write a program to help the teacher do that.

예제

예제 1

입력
3 2
1

>

<

3

>
출력
? 1 2

? 2 3

! 2

? 1 3

! 1
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.