日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

C Shuffle Cards

發布時間:2025/3/15 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C Shuffle Cards 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

???途W暑期ACM多校訓練營(第三場)? C? ?Shuffle Cards

題目:

鏈接:https://www.nowcoder.com/acm/contest/141/C
來源:牛客網

時間限制:C/C++ 1秒,其他語言2秒
空間限制:C/C++ 262144K,其他語言524288K
Special Judge, 64bit IO Format: %lld
題目描述
Eddy likes to play cards game since there are always lots of randomness in the game. For most of the cards game, the very first step in the game is shuffling the cards. And, mostly the randomness in the game is from this step. However, Eddy doubts that if the shuffling is not done well, the order of the cards is predictable!

To prove that, Eddy wants to shuffle cards and tries to predict the final order of the cards. Actually, Eddy knows only one way to shuffle cards that is taking some middle consecutive cards and put them on the top of rest. When shuffling cards, Eddy just keeps repeating this procedure. After several rounds, Eddy has lost the track of the order of cards and believes that the assumption he made is wrong. As Eddy's friend, you are watching him doing such foolish thing and easily memorizes all the moves he done. Now, you are going to tell Eddy the final order of cards as a magic to surprise him.

Eddy has showed you at first that the cards are number from 1 to N from top to bottom.

For example, there are 5 cards and Eddy has done 1 shuffling. He takes out 2-nd card from top to 4-th card from top(indexed from 1) and put them on the top of rest cards. Then, the final order of cards from top will be [2,3,4,1,5].
輸入描述:
The first line contains two space-separated integer N, M indicating the number of cards and the number of shuffling Eddy has done.
Each of following M lines contains two space-separated integer pi, si indicating that Eddy takes pi-th card from top to (pi+si-1)-th card from top(indexed from 1) and put them on the top of rest cards.


1 ≤ N, M ≤ 105
1 ≤ pi ≤ N
1 ≤ si ≤ N-pi+1
輸出描述:
Output one line contains N space-separated integers indicating the final order of the cards from top to bottom.
示例1
輸入
復制
5 1
2 3
輸出
復制
2 3 4 1 5
示例2
輸入
復制
5 2
2 3
2 3
輸出
復制
3 4 1 2 5
示例3
輸入
復制
5 3
2 3
1 4
2 4
輸出
復制
3 4 1 5 2

思路:

  rope可當做可持久化平衡樹,適用于大量、冗長的串操作

 基本操作:

? ? ? ?1)運算符:rope支持operator += -= + - < ==

  2)輸入輸出:可以用<<運算符由輸入輸出流讀入或輸出。

  3)長度/大小:調用length(),size()都可以哦

  4)插入/添加等:

  push_back(x);//在末尾添加x

  insert(pos,x);//在pos插入x,自然支持整個char數組的一次插入

  erase(pos,x);//從pos開始刪除x個

  copy(pos,len,x);//從pos開始到pos+len為止用x代替

  replace(pos,x);//從pos開始換成x

  substr(pos,x);//提取pos開始x個

  at(x)/[x];//訪問第x個元素

代碼:

#include<cstdio> #include<ext/rope> //固定寫法 using namespace std; using namespace __gnu_cxx; //固定寫法 rope<int> ss; //實質是可持久化平衡樹int n,m; int main() {scanf("%d%d",&n,&m);for(int i=1; i<=n; i++) ss.push_back(i); //放入元素(1~n)while(m--){int p,s;scanf("%d%d",&p,&s);ss = ss.substr(p-1,s)+ss.substr(0,p-1)+ss.substr(p+s-1,n-p-s+1); //重新組合三個區間 substr(起始位置,區間長度) }for(int i=0; i<n; i++){printf("%d",ss[i]);if(i==n-1)puts("");else printf(" ");}return 0; }

?

轉載于:https://www.cnblogs.com/longl/p/9381126.html

總結

以上是生活随笔為你收集整理的C Shuffle Cards的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 40到50岁中老年妇女毛片 | 亚洲最大成人网色 | 亚洲欧美成人一区二区 | 日韩一区二区免费看 | 男人天堂中文字幕 | 国产乱码精品一品二品 | 黄色片久久久 | 亚洲国产精品久久精品怡红院 | 国产亚洲一区在线 | 噜啪啪| 免费观看的av网站 | 国产精品4区 | 善良的女朋友在线观看 | 美女诱惑av | 精品91av| 日本在线精品 | 久久夜色精品 | 亚洲熟女www一区二区三区 | 国产精品中文 | 亚洲成人免费 | 爱情岛论坛成人av | 精品国产av鲁一鲁一区 | 伊人二区| av中文字幕免费观看 | 日韩欧美国产一区二区三区 | 国产黄色av | 国产成人在线看 | 亚洲国产一二三区 | 欧美日本一区二区 | 在线看av网址 | 国产一区二区视频在线观看 | 日本精品一区二区三区四区的功能 | 精品无码黑人又粗又大又长 | 51ⅴ精品国产91久久久久久 | 18禁超污无遮挡无码免费游戏 | 国产特级淫片免费看 | 日韩中文字幕国产 | www婷婷av久久久影片 | 最新国产毛片 | 亚洲高清免费视频 | 最新日韩三级 | 椎名由奈av一区二区三区 | 欧美一区二区国产 | 91精品国产欧美一区二区成人 | 黄瓜视频在线观看 | 一本到免费视频 | 国产无码日韩精品 | 日韩av手机在线免费观看 | 黄色成人免费视频 | 国产淫语对白 | 欧美老肥妇做爰bbww | 一区二区视频网 | 亚洲の无码国产の无码步美 | 色偷偷网| 国产精品专区在线观看 | 久久久久久婷婷 | 成人午夜免费网站 | 日韩精品三区 | 毛色毛片| 91天堂视频 | av黄色小说| 性猛交xxxx乱大交孕妇2十 | 国产欧美一区二区精品性色超碰 | 亚洲瑟瑟 | 一级国产片 | 国产黑丝在线 | 国产免费一级片 | 3d动漫精品h区xxxxx区 | 777精品伊人久久久久大香线蕉 | 成熟女人毛片www免费版在线 | 男女草比视频 | 国语av在线| 欧美黄色小视频 | 澳门黄色网 | 国产成人av一区二区三区 | 婷婷一区二区三区 | 69福利网| 红桃成人在线 | 男女黄色又爽大片 | 国产精品偷伦视频免费看 | 操一操 | www狠狠 | 日本国产亚洲 | 色人人| 青青草成人免费 | 人妻少妇被猛烈进入中文字幕 | 91精品国产自产91精品 | 小h片在线观看 | 亚洲精品久久久久 | 国产乱码一区二区三区播放 | 黄页在线观看 | 亚洲黄色激情 | 波多野结衣在线视频免费观看 | 国产青草视频在线观看 | 欧美日韩国产高清 | www啪啪| 久久不卡视频 | 日本激情网址 | 日韩精品一区二区三区丰满 |