660B.md (2139B)
1 Source: https://codeforces.com/problemset/problem/660/B 2 3 B. Seating On Bus 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 Consider 2*n* rows of the seats in a bus. *n* rows of the seats on the left and *n* rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4*n*. 22 23 Consider that *m* (*m* ≤ 4*n*) people occupy the seats in the bus. The passengers entering the bus are numbered from 1 to *m* (in the order of their entering the bus). The pattern of the seat occupation is as below: 24 25 1-st row left window seat, 1-st row right window seat, 2-nd row left window seat, 2-nd row right window seat, ... , *n*-th row left window seat, *n*-th row right window seat. 26 27 After occupying all the window seats (for *m* > 2*n*) the non-window seats are occupied: 28 29 1-st row left non-window seat, 1-st row right non-window seat, ... , *n*-th row left non-window seat, *n*-th row right non-window seat. 30 31 All the passengers go to a single final destination. In the final destination, the passengers get off in the given order. 32 33 1-st row left non-window seat, 1-st row left window seat, 1-st row right non-window seat, 1-st row right window seat, ... , *n*-th row left non-window seat, *n*-th row left window seat, *n*-th row right non-window seat, *n*-th row right window seat. 34 35  The seating for *n* = 9 and *m* = 36. 36 37 You are given the values *n* and *m*. Output *m* numbers from 1 to *m*, the order in which the passengers will get off the bus. 38 39 Input 40 41 The only line contains two integers, *n* and *m* (1 ≤ *n* ≤ 100, 1 ≤ *m* ≤ 4*n*) — the number of pairs of rows and the number of passengers. 42 43 Output 44 45 Print *m* distinct integers from 1 to *m* — the order in which the passengers will get off the bus. 46 47 Examples 48 49 Input 50 51 ``` 52 2 7 53 ``` 54 55 Output 56 57 ``` 58 5 1 6 2 7 3 4 59 ``` 60 61 Input 62 63 ``` 64 9 36 65 ``` 66 67 Output 68 69 ``` 70 19 1 20 2 21 3 22 4 23 5 24 6 25 7 26 8 27 9 28 10 29 11 30 12 31 13 32 14 33 15 34 16 35 17 36 18 71 ```