题目链接:

B. Seating On Bus

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Consider 2n 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 4n.

Consider that m (m ≤ 4n) 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 > 2n) 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.

Input

The only line contains two integers, n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 4n) — the number of pairs of rows and the number of passengers.

Output

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

Examples
input
2 7
output
5 1 6 2 7 3 4
input
9 36
output
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

题意:

给一个车的状态,问乘客最后下车的次序;

思路:

用队列模拟一下啦; AC代码:
/*
2014300227 660B - 6 GNU C++11 Accepted 31 ms 2176 KB
*/
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+;
typedef long long ll;
const double PI=acos(-1.0);
queue<int>qu1,qu2,qu3,qu4;
int n,m,num1,num2,num3,num4;
int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=m&&i<=*n; )
{
if(i<=m&&num1<=n){
qu1.push(i);
num1++;
i++;
}
if(i<=m&&num2<=n)
{
qu2.push(i);
num2++;
i++;
}
}
for(int i=*n+;i<=m;)
{
if(i<=m){ qu3.push(i);
i++;} if(i<=m){qu4.push(i);
i++;}
}
while(m)
{
if(!qu3.empty())
{
printf("%d ",qu3.front());
qu3.pop();
m--;
}
if(!qu1.empty())
{
printf("%d ",qu1.front());
qu1.pop();
m--;
}
if(!qu4.empty())
{
printf("%d ",qu4.front());
qu4.pop();
m--;
}
if(!qu2.empty())
{
printf("%d ",qu2.front());
qu2.pop();
m--;
}
} return ;
}

codeforces 660B B. Seating On Bus(模拟)的更多相关文章

  1. Educational Codeforces Round 11B. Seating On Bus 模拟

    地址:http://codeforces.com/contest/660/problem/B 题目: B. Seating On Bus time limit per test 1 second me ...

  2. Educational Codeforces Round 11 B. Seating On Bus 水题

    B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...

  3. Co-prime Array&&Seating On Bus(两道水题)

     Co-prime Array Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Su ...

  4. CodeForces 660B Seating On Bus

    模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...

  5. Codeforces Round #436 (Div. 2)C. Bus 模拟

    C. Bus time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input out ...

  6. codeforces 723B Text Document Analysis(字符串模拟,)

    题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...

  7. Codeforces Round #304 C(Div. 2)(模拟)

    题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张 ...

  8. Codeforces 749C:Voting(暴力模拟)

    http://codeforces.com/problemset/problem/749/C 题意:有n个人投票,分为 D 和 R 两派,从1~n的顺序投票,轮到某人投票的时候,他可以将对方的一个人K ...

  9. Educational Codeforces Round 2 A. Extract Numbers 模拟题

    A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...

随机推荐

  1. npm安装package.json

    npm安装package.json时,直接转到当前项目目录下,用命令npm install 或npm install --save-dev安装即可,自动将package.json中的模块安装到node ...

  2. Material Design Get Started

    使用Material Design设计应用: Take a look at the material design specification. Apply the material theme to ...

  3. 浅谈对TDD的看法

    程序猿对TDD这个词一定不陌生.近几年比較火.英文全称Test-Driven Development,測试驱动开发. 它要求在编写某个功能的代码之前先编写測试代码,然后仅仅编写使測试通过的功能代码,通 ...

  4. centos6.6安装mysql5.5

    在mysql官网下载mysql-5.5.54-linux2.6-x86_64.tar.gz解压:tar -zxvf  mysql-5.5.54-linux2.6-x86_64.tar.gz修改名字mv ...

  5. Struts2学习五----------指定多个配置文件

    © 版权声明:本文为博主原创文章,转载请注明出处 指定多个配置文件 - 在Struts2配置文件中使用include可指定多个配置文件 实例 1.项目结构 2.pom.xml <project ...

  6. GitHub使用问题(遇到一个记一个)

    1.如何创建文件夹: 如图,Create new files,点击后,若需要创建文件,输入文件名即可,但如果创建的是文件夹,需要在文件夹名后 加一个 '/'斜杠,然后就变成文件夹了

  7. 宜信开源|微服务任务调度平台SIA-TASK入手实践

    引言 最近宜信开源微服务任务调度平台SIA-TASK,SIA-TASK属于分布式的任务调度平台,使用起来简单方便,非常容易入手,部署搭建好SIA-TASK任务调度平台之后,编写TASK后配置JOB进行 ...

  8. TP实例化模型的两种方式 M() D()

    TP框架中实例化模型的两种方式 #如果使用自己自定义的函数,那么就用D $mode=D('model'); #如果使用是系统自带的函数,那么就是用M $model=M('model');

  9. android Bluetooth-蓝牙

    bluetooth 一.开启蓝牙 1.获取BluetoothAdapter BluetoothAdapter.getDefaultAdapter() 2.判断手机设备是否 有蓝牙模块 3.开启蓝牙设备 ...

  10. UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position xxx ordinal not in range(12

    python在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报这样的错UnicodeDecodeError: 'ascii' codec can't deco ...