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

18449번 - Cool Pairs 스페셜 저지다국어

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

문제

You have two permutations of n elements, p1, p2, . . . , pn and q1, q2, . . . , qn, and one integer k.

You need to find two integer arrays, a and b, with the following properties:

  • The elements of the arrays must be integers such that −n ≤ ai, bi ≤ n.
  • The permutations induce the following order: ap1 ≤ ap2 ≤ . . . ≤ apn and bq1 ≤ bq2 ≤ . . . ≤ bqn.
  • A pair (i, j) is cool if i < j and ai + bj < 0. The number of cool pairs must be exactly k.

입력

The first line of the input contains two integers n and k: the number of elements and the required number of cool pairs (1 ≤ n ≤ 300 000, 0 ≤ k ≤ n·(n−1)/2).

The second line contains n space-separated integers: the permutation p1, p2, . . . , pn.

The third line contains n space-separated integers: the permutation q1, q2, . . . , qn.

It is guaranteed that each integer from 1 to n appears exactly once in each permutation.

출력

If there is no such pair of integer arrays that the number of cool pairs is equal to k, print “No” on a single line.

Otherwise, print “Yes” on the first line, and print the arrays a and b on the next two lines. Separate array elements by spaces.

제한

예제 입력 1

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

예제 출력 1

Yes
2 3 -1 5 1
-5 -3 -2 -2 0

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2019 > Day 1: 300iq Contest C번

  • 문제를 만든 사람: 300iq
(追記) (追記ここまで)

출처

대학교 대회

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

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