6682.Two Sets

Time Limit: 1s Memory Limit: 512MB

Your task is to divide the numbers $1,2,\ldots,n$ into two sets of equal sum.

Input Format(From the terminal/stdin)

The only input line contains an integer $n$ .

  • $1 \le n \le 10^6$

Output Format(To the terminal/stdout)

Print "YES", if the division is possible, and "NO" otherwise.

After this, if the division is possible, print an example of how to create the sets. First, print the number of elements in the first set followed by the elements themselves in a separate line, and then, print the second set in a similar way.

Sample Input 1

Copy
7
 \n

Sample Output 1 special judge

Copy
YES
4
1 2 4 7
3
3 5 6
   \n
 \n
 · · · \n
 \n
 · · \n

Sample Input 2

Copy
6
 \n

Sample Output 2 special judge

Copy
NO
  \n
Source: CSES, Introductory Problems, 1092

Submit

请先 登录

© 2025 FAQs