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

27489번 - Matching Numbers 스페셜 저지다국어

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

문제

You are given an integer $n$. Pair the integers 1ドル$ to 2ドルn$ (i.e. each integer should be in exactly one pair) so that each sum of matched pairs is consecutive and distinct.

Formally, let $(a_i, b_i)$ be the pairs that you matched. $\{a_1, b_1, a_2, b_2, \ldots, a_n, b_n\}$ should be a permutation of $\{1, 2, \ldots, 2n\}$. Let the sorted list of $\{a_1+b_1, a_2+b_2, \ldots, a_n+b_n\}$ be $s_1 < s_2 < \ldots < s_n$. We must have $s_{i+1}-s_i = 1$ for 1ドル \le i \le n - 1$.

입력

Each test contains multiple test cases. The first line contains the number of test cases $t$ (1ドル \le t \le 500$). The description of the test cases follows.

For each test case, a single integer $n$ (1ドル \leq n \leq 10^5$) is given.

It is guaranteed that the sum of $n$ over all test cases doesn't exceed 10ドル^5$.

출력

For each test case, if it is impossible to make such a pairing, print "No".

Otherwise, print "Yes" followed by $n$ lines.

At each line, print two integers that are paired.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

If there are multiple solutions, print any.

제한

예제 입력 1

4
1
2
3
4

예제 출력 1

Yes
1 2
No
Yes
1 6
3 5
4 2
No

For the third test case, each integer from 1ドル$ to 6ドル$ appears once.
The sums of matched pairs are 4ドル+2=6,ドル 1ドル+6=7,ドル and 3ドル+5=8,ドル which are consecutive and distinct.

힌트

출처

Contest > Codeforces > Codeforces Round 851 (Div. 2) C번

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

출처

대학교 대회

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

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