#CCBCHBAHAI0000131. Điền mảng IV (Array Fill IV)
Điền mảng IV (Array Fill IV)
Array Fill IV
Source: beecrowd
Version: Phuoc Hung OJ Extended
Problem Statement
Read exactly integers in their input order. Maintain two temporary arrays, each with capacity :
parstores even values;imparstores odd values.
Each value is appended to the corresponding temporary array. Whenever one temporary array reaches exactly elements, immediately print all five elements in their stored order using indices from through , then clear that temporary array so it can be reused for later values of the same parity.
After all values have been processed, some elements may remain in the temporary arrays. Print the remaining odd values first, then the remaining even values. The original order within each parity group must be preserved.
Input
The input contains exactly lines, each containing one integer .
Output
Print each value on its own line using exactly one of the forms
par[i] = x
or
impar[i] = x
where is the current index in the temporary array and restarts at after that array is flushed at size .
Subtasks
Subtask 1 (100 points): exactly integers are given and . The magnitude bound is a PHOJ data configuration; the partitioning, flushing, and output order are unchanged.
Examples
Input
1
3
4
-4
2
3
8
2
5
-7
54
76
789
23
98
Output
par[0] = 4
par[1] = -4
par[2] = 2
par[3] = 8
par[4] = 2
impar[0] = 1
impar[1] = 3
impar[2] = 3
impar[3] = 5
impar[4] = -7
impar[0] = 789
impar[1] = 23
par[0] = 54
par[1] = 76
par[2] = 98
Explanation
The first five even values are . When the fifth even value arrives, par is full, so those five lines are printed immediately.
The first five odd values are . When -7 is read, impar becomes full and is printed.
The remaining odd values are , while the remaining even values are . At the end, the remaining odd values are printed before the remaining even values.