codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

300A.md (1680B)


      1 Source: https://codeforces.com/problemset/problem/300/A
      2 
      3 A. Array
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Vitaly has an array of *n* distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold:
     22 
     23 1. The product of all numbers in the first set is less than zero ( < 0).
     24 2. The product of all numbers in the second set is greater than zero ( > 0).
     25 3. The product of all numbers in the third set is equal to zero.
     26 4. Each number from the initial array must occur in exactly one set.
     27 
     28 Help Vitaly. Divide the given array.
     29 
     30 Input
     31 
     32 The first line of the input contains integer *n* (3 ≤ *n* ≤ 100). The second line contains *n* space-separated distinct integers *a*1, *a*2, ..., *a**n* (|*a**i*| ≤ 103) — the array elements.
     33 
     34 Output
     35 
     36 In the first line print integer *n*1 (*n*1 > 0) — the number of elements in the first set. Then print *n*1 numbers — the elements that got to the first set.
     37 
     38 In the next line print integer *n*2 (*n*2 > 0) — the number of elements in the second set. Then print *n*2 numbers — the elements that got to the second set.
     39 
     40 In the next line print integer *n*3 (*n*3 > 0) — the number of elements in the third set. Then print *n*3 numbers — the elements that got to the third set.
     41 
     42 The printed sets must meet the described conditions. It is guaranteed that the solution exists. If there are several solutions, you are allowed to print any of them.
     43 
     44 Examples
     45 
     46 Input
     47 
     48 ```
     49 3  
     50 -1 2 0
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 1 -1  
     57 1 2  
     58 1 0
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 4  
     65 -1 -2 -3 0
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 1 -1  
     72 2 -3 -2  
     73 1 0
     74 ```