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

19484번 - Weltall 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 256 MB114330.000%

문제

You're on the humanity's first ever mission into another galaxy. The problem is, the galaxy is quite far away, so you've got plenty of time on your hands.

You've decided to spend the time by learning to do various jobs required to run your spaceship. There are $n$ people on the spaceship, each performing one of the $n$ different roles. Each person is an expert in exactly one of the roles, and for each role there's exactly one expert in this role. We will number the people from 1 to $n$ and roles also from 1 to $n$ in such a way that person $i$ is an expert in role $i$.

On each day, we need to assign people to roles in such a way that everybody has a role, and every role has somebody performing it --- in other words, we need to pick a permutation of numbers between 1 and $n$: $a_1,ドル $a_2,ドル \dots, $a_n$.

We want to assign people to roles in such a way that exactly $k$ people are assigned to roles they are experts in (to make sure the spaceship still flies), and the remaining $n-k$ people are assigned to roles they are not experts in (to make sure they can learn). In other words, there must be exactly $k$ positions $i$ such that $a_i=i$.

There are many such assignments, and repeating the same assignment slows down the learning, so on day $d$ of the flight we will use the $d$-th such assignment in lexicographical order. One assignment precedes the other in lexicographical order if and only if the person with the smallest number that has a different role between them has a role with a smaller number. In other words, there exists such $i$ such that $a_i < b_i,ドル and for all $j < i$ we have $a_j = b_j$.

Given $n,ドル $k,ドル and $d,ドル you need to find that assignment.

입력

The first line of the input file contains the number $t$ of testcases to solve, 1ドル \le t \le 50$. The next $t$ lines contain 3 integers each: $n,ドル $k$ and $d,ドル where 1ドル \le n \le 500,ドル 0ドル \le k \le n,ドル and $d$ is between 1 and the total number of different assignments of $n$ people to roles with exactly $k$ people performing their expert roles, inclusive.

출력

For each testcase output one line containing the corresponding assignment. That line should contain $n$ space-separated integers, each between 1 and $n$.

제한

예제 입력 1

8
4 1 1
4 1 2
4 1 3
4 1 4
4 1 5
4 1 6
4 1 7
4 1 8

예제 출력 1

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

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2016 > Day 5: Petr Mitrichev Contest 14 J번

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

출처

대학교 대회

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

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