CF660B.Seating On Bus

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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_.

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:

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.

After occupying all the window seats (for m > 2_n_) the non-window seats are occupied:

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.

All the passengers go to a single final destination. In the final destination, the passengers get off in the given order.

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.

The seating for n = 9 and m = 36.

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.

考虑一辆公交车中有 2n2n 行座位:左侧 nn 行,右侧 nn 行。每行可坐两人,因此公交车的总容量为 4n4n。

现有 mm(m≤4nm \leq 4n)名乘客登上该公交车。上车乘客按上车顺序编号为 11 到 mm。座位占用模式如下:

第 11 行左窗座、第 11 行右窗座、第 22 行左窗座、第 22 行右窗座、……、第 nn 行左窗座、第 nn 行右窗座。

当所有窗座均被占满后(即 m>2nm > 2n 时),再依次占用非窗座:

第 11 行左非窗座、第 11 行右非窗座、……、第 nn 行左非窗座、第 nn 行右非窗座。

所有乘客均前往同一终点站。在终点站,乘客按如下顺序下车:

第 11 行左非窗座、第 11 行左窗座、第 11 行右非窗座、第 11 行右窗座、……、第 nn 行左非窗座、第 nn 行左窗座、第 nn 行右非窗座、第 nn 行右窗座。

当 n=9n = 9 且 m=36m = 36 时的座位安排示意图。

给定 nn 和 mm 的值,请输出 11 到 mm 这 mm 个数字的一个排列,表示乘客下车的顺序。

输入格式

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.

唯一一行包含两个整数 nn 和 mm(1leqnleq1001leq n leq 100,1leqmleq4n1 leq m leq 4n)—— 分别表示行对的数量和乘客数量。

输出格式

Print m distinct integers from 1 to m — the order in which the passengers will get off the bus.

输出 m 个互不相同的整数,取值范围为 1 到 m —— 表示乘客下车的顺序。

输入输出样例

  • 输入#1

    2 7

    输出#1

    5 1 6 2 7 3 4
  • 输入#2

    9 36

    输出#2

    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

输入解题思路,AI测评打分。不知道怎么写?

首页