PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000155. Xây dựng mảng (Constructing the Array)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Xây dựng mảng (Constructing the Array)
Constructing the Array
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Start with an array of zeros. Perform operations numbered through . At operation , choose a longest contiguous segment consisting only of zeros; among equal-length segments choose the leftmost.
If the chosen segment is , write at position , taking the left middle position when the length is even. Output the resulting array after all operations.
Input
The input contains one integer .
Output
Print the array elements after the described operations.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
5
Output
2 4 1 3 5
Explanation
For , first place at position . The two length-two zero segments are and , so place at position , then at position . Finally put at position and at position . The answer is .