1042 Shuffling Machine (20 分)
 

Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by performing inadequate shuffles, many casinos employ automatic shuffling machines. Your task is to simulate a shuffling machine.

The machine shuffles a deck of 54 cards according to a given random order and repeats for a given number of times. It is assumed that the initial status of a card deck is in the following order:

S1, S2, ..., S13,
H1, H2, ..., H13,
C1, C2, ..., C13,
D1, D2, ..., D13,
J1, J2

where "S" stands for "Spade", "H" for "Heart", "C" for "Club", "D" for "Diamond", and "J" for "Joker". A given order is a permutation of distinct integers in [1, 54]. If the number at the i-th position is j, it means to move the card from position i to position j. For example, suppose we only have 5 cards: S3, H5, C1, D13 and J2. Given a shuffling order {4, 2, 5, 3, 1}, the result will be: J2, H5, D13, S3, C1. If we are to repeat the shuffling again, the result will be: C1, H5, S3, J2, D13.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive integer K (≤) which is the number of repeat times. Then the next line contains the given order. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print the shuffling results in one line. All the cards are separated by a space, and there must be no extra space at the end of the line.

Sample Input:

2
36 52 37 38 3 39 40 53 54 41 11 12 13 42 43 44 2 4 23 24 25 26 27 6 7 8 48 49 50 51 9 10 14 15 16 5 17 18 19 1 20 21 22 28 29 30 31 32 33 34 35 45 46 47

Sample Output:

S7 C11 C10 C12 S1 H7 H8 H9 D8 D9 S11 S12 S13 D10 D11 D12 S3 S4 S6 S10 H1 H2 C13 D2 D3 D4 H6 H3 D13 J1 J2 C1 C2 C3 C4 D1 S5 H5 H11 H12 C6 C7 C8 C9 S2 S8 S9 H10 D5 D6 D7 H4 H13 C5

#include<bits/stdc++.h>
using namespace std;
typedef long long ll; vector<string> vec;
int num[];
int a[]; int main(){
vec.push_back("*");
for(int i=;i <= ;i++){
string tt = "S";
string temp = to_string(i);
tt += temp;
vec.push_back(tt);
}
for(int i=;i <= ;i++){
string tt = "H";
string temp = to_string(i);
tt += temp;
vec.push_back(tt);
}for(int i=;i <= ;i++){
string tt = "C";
string temp = to_string(i);
tt += temp;
vec.push_back(tt);
}for(int i=;i <= ;i++){
string tt = "D";
string temp = to_string(i);
tt += temp;
vec.push_back(tt);
}
vec.push_back("J1");
vec.push_back("J2"); // for(auto x:vec) cout << x << " "; map<int,int>mp; int k;
cin >> k;
for(int i=;i <= ;i++){
int x; cin >> x;
a[i] = i;
num[i] = x;
}
while(k--){
for(int i=;i <= ;i++){
mp[num[i]] = a[i];
}
map<int,int>::iterator it;
int j=;
for(it=mp.begin();it!=mp.end();it++,j++){
// cout << it->first << " " << it->second << endl;
a[j] = it->second;
}
mp.clear();
}
for(int i=;i <= ;i++){
cout << vec[a[i]];
if(i!=) cout << " ";
} return ;
}

PAT 1042 Shuffling Machine (20 分)的更多相关文章

  1. PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...

  2. PAT 甲级 1042 Shuffling Machine (20 分)(简单题)

    1042 Shuffling Machine (20 分)   Shuffling is a procedure used to randomize a deck of playing cards. ...

  3. PAT 1042. Shuffling Machine (20)

    1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...

  4. PAT Advanced 1042 Shuffling Machine (20 分)(知识点:利用sstream进行转换int和string)

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

  5. 1042 Shuffling Machine (20分)(水)

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

  6. 【PAT甲级】1042 Shuffling Machine (20 分)

    题意: 输入洗牌次数K(<=20),输入54张牌每次洗入的位置(不是交换的位置),输出洗好的牌. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC ...

  7. PAT 1042 Shuffling Machine[难]

    1042 Shuffling Machine (20)(20 分) Shuffling is a procedure used to randomize a deck of playing cards ...

  8. pat 1042 Shuffling Machine(20 分)

    1042 Shuffling Machine(20 分) Shuffling is a procedure used to randomize a deck of playing cards. Bec ...

  9. PAT(A) 1042. Shuffling Machine (20)

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

随机推荐

  1. pytest_用例运行级别_函数级

    '''  函数级(setup_function/teardown_function只对函数用例生 效(不在类中)在类中是用该方法不生效 ''' import pytest def setup_mod ...

  2. VB.NET导出Excel 轻松实现Excel的服务器与客户端交换 服务器不安装Office

    说来VB.Net这个也是之前的一个项目中用到的.今天拿来总结下用途,项目需求,不让在服务器安装Office办公软件.这个也是煞费了一顿. 主要的思路就是 在导出的时候,利用DataTable做中间变量 ...

  3. git修改commiter date

    GIT: change commit date to author date git filter-branch --env-filter 'export GIT_COMMITTER_DATE=&qu ...

  4. phpstorm中sass编译时目录或内容包含中文字符报错

    ruby版本:ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32] sass版本:Sass 3.4.24 (Selective Steve) ...

  5. QTP加载第三方DLL(C#)实现清除IE缓存(转)

    由于QTP的默认编程语言是VBS, 而VBS是一种相对来说功能比较局限的脚本语言,因此我们在编写自动化测试脚本时会有很多功能无法很好的实现. 相对来说c#是一种高级编程语言, 可以实现大多数windo ...

  6. Learning OSG programing---osgScribe

    Learning OSG programing---osgScribe Scribe可以翻译为素描,抄写等.本例通过在模型表面添加一层素描,来显示模型的骨架. 关键代码: osg::ref_ptr&l ...

  7. 年度重大升级,IntelliJ IDEA 2019.2 稳定版发布

    文章转载自 OSCHINA 社区 [http://www.oschina.net] 期待已久. 7月24日,JetBrains 正式发布了 IntelliJ IDEA 2019.2 稳定版. 作为 I ...

  8. FastReport.net 使用 WebForm 实现打印 最简单版

    1.安装demo 2.设计模版 设计器 -->report-->添加数据源-->添加sql查询->起名字(车信息)下一步-->填写sql语句(select top 1 * ...

  9. luoguP3258 [JLOI2014]松鼠的新家 题解(树上差分)

    P3258 [JLOI2014]松鼠的新家  题目 树上差分:树上差分总结 #include<iostream> #include<cstdlib> #include<c ...

  10. Ubuntu下安装chrome浏览器步骤

    进入 Ubuntu 18.04 桌面,按下 Ctrl + Alt + t 键盘组合键,启动终端. 也可以按下 Win 键(或叫 Super 键),在 Dash 的搜索框中输入 terminal 或“终 ...