#CCBCHBAHAI0000080. Tách âm - zero - dương vào ba mảng (Split Negative, Zero, and Positive Values)
Tách âm - zero - dương vào ba mảng (Split Negative, Zero, and Positive Values)
Split Negative, Zero, and Positive Values
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given , split it into three stable subsequences:
$$N=[a_i\mid a_i<0],\qquad Z=[a_i\mid a_i=0],\qquad P=[a_i\mid a_i>0].$$Each subsequence preserves original order, and their sizes sum to .
Input
The first line contains . The second line contains integers .
Output
Print three lines for negative, zero, and positive groups. Each line starts with its logical size followed by its elements; an empty group is printed as just 0.
Subtask
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Example
Input
8
-4 0 7 -1 0 3 -9 2
Output
3 -4 -1 -9
2 0 0
3 7 3 2
Explanation
The output follows directly from the mathematical definition above.