Q3

mail@pastecode.io avatar
unknown
c_cpp
11 days ago
777 B
2
Indexable
Never
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int k, q, r;
    cin >> k >> q >> r;
    string s;
    cin >> s;

    vector<vector<int>> permutations(q, vector<int>(k));
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < k; ++j) {
            cin >> permutations[i][j];
        }
    }

    vector<string> store(q);
    for (int i = 0; i < q; ++i) {
        string new_str(s);
        for (int j = 0; j < k; ++j) {
            new_str[permutations[i][j] - 1] = s[j];
        }
        store[i] = new_str;
        s = new_str;
    }

    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < q; ++j) {
            cout << store[j][i];
        }
        cout << endl;
    }

}
Leave a Comment