1174B.md (1325B)
1 Source: https://codeforces.com/problemset/problem/1174/B 2 3 B. Ehab Is an Odd Person 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You're given an array $a$ of length $n$. You can perform the following operation on it as many times as you want: 22 23 * Pick two integers $i$ and $j$ $(1 \le i,j \le n)$ such that $a_i+a_j$ is odd, then swap $a_i$ and $a_j$. 24 25 What is lexicographically the smallest array you can obtain? 26 27 An array $x$ is [lexicographically smaller](https://en.wikipedia.org/wiki/Lexicographical_order) than an array $y$ if there exists an index $i$ such that $x_i \lt y_i$, and $x_j=y_j$ for all $1 \le j \lt i$. Less formally, at the first index $i$ in which they differ, $x_i \lt y_i$ 28 29 Input 30 31 The first line contains an integer $n$ ($1 \le n \le 10^5$) — the number of elements in the array $a$. 32 33 The second line contains $n$ space-separated integers $a_1$, $a_2$, $\ldots$, $a_{n}$ ($1 \le a_i \le 10^9$) — the elements of the array $a$. 34 35 Output 36 37 The only line contains $n$ space-separated integers, the lexicographically smallest array you can obtain. 38 39 Examples 40 41 Input 42 43 ``` 44 3 45 4 1 7 46 ``` 47 48 Output 49 50 ``` 51 1 4 7 52 ``` 53 54 Input 55 56 ``` 57 2 58 1 1 59 ``` 60 61 Output 62 63 ``` 64 1 1 65 ``` 66 67 Note 68 69 In the first example, we can swap $1$ and $4$ since $1+4=5$, which is odd.