A1042 Shuffling Machine (20)

摘要
Title: A1042 Shuffling Machine (20)
Tag: 模拟
Memory Limit: 64 MB
Time Limit: 1000 ms

Powered by:NEFU AB-IN

Link

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

  • 思路

    按题意模拟即可

  • 代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    /*
    * @Author: NEFU AB-IN
    * @Date: 2023-01-10 18:35:08
    * @FilePath: \GPLT\A1042\A1042.cpp
    * @LastEditTime: 2023-01-10 18:52:03
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define int long long
    #undef int

    #define SZ(X) ((int)(X).size())
    #define ALL(X) (X).begin(), (X).end()
    #define IOS \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr); \
    cout.tie(nullptr)
    #define DEBUG(X) cout << #X << ": " << X << '\n'
    typedef pair<int, int> PII;

    const int N = 55, INF = 0x3f3f3f3f;

    signed main()
    {
    IOS;
    vector<string> ord(1);
    vector<char> v = {'S', 'H', 'C', 'D'};
    for (int i = 0; i < 4; ++i)
    {
    char pre = v[i];
    for (int j = 1; j <= 13; ++j)
    {
    string s = to_string(j);
    s = pre + s;
    ord.push_back(s);
    }
    }
    ord.push_back("J1");
    ord.push_back("J2");

    int k;
    cin >> k;
    vector<int> mp(N);
    for (int i = 1; i < N; ++i)
    {
    cin >> mp[i];
    }

    while (k--)
    {
    vector<string> new_ord(N);
    for (int i = 1; i < N; ++i)
    {
    new_ord[mp[i]] = ord[i];
    }
    ord = new_ord;
    }
    for (int i = 1; i < N; ++i)
    {
    cout << ord[i] << " "[i == N - 1];
    }
    return 0;
    }
使用搜索:谷歌必应百度