题目链接:http://codeforces.com/problemset/problem/669/D

D. Little Artem and Dance
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together.

More detailed, there are n pairs of boys and girls standing in a circle. Initially, boy number 1 dances with a girl number 1, boy number 2 dances with a girl number 2 and so on. Girls are numbered in the clockwise order. During the dance different moves are announced and all pairs perform this moves. While performing moves boys move along the circle, while girls always stay at their initial position. For the purpose of this problem we consider two different types of moves:

  1. Value x and some direction are announced, and all boys move x positions in the corresponding direction.
  2. Boys dancing with even-indexed girls swap positions with boys who are dancing with odd-indexed girls. That is the one who was dancing with the girl 1 swaps with the one who was dancing with the girl number 2, while the one who was dancing with girl number 3 swaps with the one who was dancing with the girl number 4 and so one. It's guaranteed that n is even.

Your task is to determine the final position of each boy.

Input

The first line of the input contains two integers n and q (2 ≤ n ≤ 1 000 000, 1 ≤ q ≤ 2 000 000) — the number of couples in the rueda and the number of commands to perform, respectively. It's guaranteed that n is even.

Next q lines contain the descriptions of the commands. Each command has type as the integer 1 or 2 first. Command of the first type is given as x ( - n ≤ x ≤ n), where 0 ≤ x ≤ n means all boys moves x girls in clockwise direction, while  - x means all boys move x positions in counter-clockwise direction. There is no other input for commands of the second type.

Output

Output n integers, the i-th of them should be equal to the index of boy the i-th girl is dancing with after performing all q moves.

Examples
Input

Copy

6 31 221 2

Output

Copy

4 3 6 5 2 1

Input

Copy

2 31 121 -2

Output

Copy

1 2

Input

Copy

4 221 3

Output

Copy

1 4 3 2

题目大意:输入n,代表有n对男女,1···n。所有人围成一个圈, 刚开始男1与女1,男2与女2···对应,q代表有q次操作,如果输入的是1,则所有男的移动x位,正代表顺时针,负代表逆时针。如果输入的是2,则男1与男2交换位子,男3与男4交换位子···个人思路:不论怎么操作,其实男1后面两位一定是3,后面4位一定是5·····男2后面两位一定是4,后面四位一定是6····,所以我们只要记录男1和男2的位子,就能知道所有人的位子了看代码(但这题要用scanf,不然会超时)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
const int maxn=1e6+10;
const int maxk=100+10;
const int maxx=1e4+10;
const ll maxa=43200;
#define INF 0x3f3f3f3f3f3f
int a[maxn];
int main()
{int n,q,p1,p2,m,x;scanf("%d%d",&n,&q);p1=0;p2=1;for(int i=1;i<=q;i++){scanf("%d",&m);if(m==1){scanf("%d",&x);if(x<0)x+=n;p1+=x;p2+=x;p1%=n;p2%=n;}else{if(p1%2==0){p1+=1;}else{p1-=1;//p1=(p1+n)%n;
            }if(p2%2==0){p2+=1;}else{p2-=1;//  p2=(p2+6)%6;
            }}}a[p1]=1;a[p2]=2;int t=n/2;int sum=2;while(--t){sum+=2;a[(p2+2)%n]=sum;p2=(p2+2)%n;}t=n-n/2;sum=1;while(--t){sum+=2;a[(p1+2)%n]=sum;p1=(p1+2)%n;}for(int i=0;i<n;i++)printf("%d ",a[i]);printf("\n");return 0;
}

转载于:https://www.cnblogs.com/caijiaming/p/9350227.html

D. Little Artem and Dance相关推荐

  1. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance 模拟

    D. Little Artem and Dance 题目连接: http://www.codeforces.com/contest/669/problem/D Description Little A ...

  2. [4.6校内训练赛]

    来自FallDream的博客,未经允许,请勿转载,谢谢. A.[cf577b]Modulo Sum 给定n个数,问是否有一个子序列相加的和取余m为0  n<=10^6,m<=1000 题解 ...

  3. 持续集成之戏说Check-in Dance

    <infoq> 众所周知,敏捷软件开发方法中有多种最佳实践,既有管理方面的,也有技术方面的.在尝试敏捷之初,并不是每个团队都能使用全部最佳实践,也不是每个实践都能在短时间内见效.但其中有一 ...

  4. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) B. Little Artem and Grasshopper 模拟题...

    B. Little Artem and Grasshopper 题目连接: http://www.codeforces.com/contest/669/problem/B Description Li ...

  5. 牛客 - Dance with a stick(大风车模型)

    题目链接:点击查看 题目大意:二维平面给出 nnn 个点,满足任意三个点不在一条直线上.需要选出一条经过某个点的有向直线,满足执行 "大风车" 后直线的角度反转到 18018018 ...

  6. 对 Strong-Weak Dance的思考

    在使用 Block 时,除了使用 __weak 修饰符避免循环引用外,还有一点经常容易忘记.苹果把它称为:"Strong-Weak Dance". 问题来源 这是一种 强引用 -- ...

  7. CF641D. Little Artem and Random Variable

    CF641D. Little Artem and Random Variable Solution 设给定的两个序列为mx1..n,mn1..nmx_{1..n},mn_{1..n}mx1..n​,m ...

  8. CodeForces - 641ELittle Artem and Time Machine——map+树状数组

    [题目描述] CodeForces - 641ELittle Artem and Time Machine [题目分析] 题目的意思大概是有三种操作 1.在时间t加入一个数字x 2.在时间t删除一个数 ...

  9. 推荐 | Transformer最新成果!Learn to Dance with AIST++: Music Conditioned 3D Dance Generation!

    论文:Learn to Dance with AIST++: Music Conditioned 3D Dance Generation 数据集:https://google.github.io/ai ...

最新文章

  1. 自动红眼移除算法 附c++完整代码
  2. 深入理解Java 8 Lambda(语言篇——lambda,方法引用,目标类型和默认方法)
  3. [实现]Javascript代码的另一种压缩与加密方法——代码图片转换
  4. python redis 消息队列_python中利用redis构建任务队列(queue)
  5. css3教程:弹性盒模型
  6. Avdshare Audio Converter 7中文版
  7. 高通QXDM抓modem log
  8. jquery $.each()函数编程实例五则图解
  9. mysql所有知识点总结_MySQL知识点总结
  10. 破解前端面试系列(3):如何搞定纸上代码环节?
  11. VTK:可视化之RotateActor
  12. 绝对布局优势_街电福建全场景布局持续深化,构建全时续电服务强化行业领先优势...
  13. angular指令监听ng-repeat渲染完成后执行自定义事件方法
  14. 【转载】前端开发之CSS兼容写法经验总结
  15. struts2、ajax实现前后端交互
  16. Ugly Windows
  17. Zookeeper 客户端 Curator 使用详解
  18. CentOS配置postgresql+postsql
  19. mysql查看当前有哪些库_MySQL查看当前数据库库
  20. 网站性能优化之DNS Prefetch

热门文章

  1. INSTALLSHIELD11.5中打包水晶报表的问题,ScriptProject与ScriiptMSIProject差异引起的错误!...
  2. directx11编程中遇到的错误及解决方法
  3. SQLSERVER 创建ODBC 报错的解决办法 SQLState:‘01000‘的解决方案
  4. SpringBoot-技术专区-详细打印启动时异常堆栈信息
  5. 美团知识图谱问答技术及在商家推荐回复场景中的实践与探索
  6. python中get和getall_Scrapy框架get() 、getall() 、extract() 、extract_first()的区别
  7. 深度学习主流框架介绍(PyTorch、TensorFlow、Keras、Caffe、Theano、MXNET)
  8. 【PE】手动给PE文件添加一段代码MessageBoxA
  9. testNG-失败用例重跑机制
  10. 怎样制作网吧服务器,网吧游戏服务器制作的过程是怎样的