Artillery | 프로그래밍의 벗 PivotOJ
PivotOJ

Artillery

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2019-20 openBOJ 29914

문제

The good soldier Švejk, serving in the 14-th mounted artillery regiment, has reached České Budějovice. Unexpectedly, general Finck von Finckenstein arrives to inspect the regiment. Lieutenant Lukaš must line up NN cannons (all horse-drawn, of course) and fire each one exactly once.

Unfortunately, the shots scare the horses. The effect is worse when consecutive shots are fired from cannons close to each other. Therefore, Lieutenant Lukaš asks Švejk to devise a firing sequence where consecutive shots are fired from cannons that are as far from each other as possible. More precisely, the sum of the distances is to be maximized.

A firing sequence for NN cannons is a reordering PP of the numbers 1N1 \dots N, where P1P_1 is the number of the cannon fired first, PiP_i the number of the cannon fired ii-th in the sequence, and PNP_N the number of the cannon fired last. The sum of distances for such a sequence is S=P1P2+P2P3++PN1PNS = |P_1-P_2| + |P_2-P_3| + \dots + |P_{N-1}-P_N|.

When listing sequences, they are orderd so that when the first i1i-1 elements of two sequences PP and QQ match, but the ii-th elements differ, the sequence with the smaller ii-th element comes earlier in the list.

Lieutenant Lukaš knows that the favourite number of general Finck von Finckenstein is MM, and suspects the general is likely to request the cannons to be fired in the order of the sequence on the MM-th position in the list of possible sequences.

To help Švejk, write a program that computes

  • SS, the maximal possible sum of distances;
  • KK, the total number of firing sequences with the maximal sum;
  • the first sequence in the list of all sequences with the maximal sum;
  • the MM-th sequence in the list of all sequences with the maximal sum.

입력

\sis The only line of input contains two integers: NN, the number of cannons (2N1052 \le N \le 10^5), and MM, the favourite number of general Finck von Finckenstein (1Mmin(1018,K)1 \le M \le \min(10^{18}, K)), where KK is the total number of sequences with the maximal sum of distances.

출력

The first line of output should contain SS, the maximal possible sum of distances when NN cannons are fired in some sequence, and K1000000007K \bmod 1\,000\,000\,007, where KK is the total number of sequences with the sum SS. The second line should contain NN integers: the first sequence in the list of all sequences with the maximal sum. The third line should also contain NN integers: the MM-th sequence in the list of all sequences with the maximal sum.

예제

예제 1

입력
5 3
출력
11 8
2 4 1 5 3
3 1 5 2 4
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.