Q3

 avatar
unknown
c_cpp
8 months ago
777 B
4
Indexable
#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;
    }

}
Editor is loading...
Leave a Comment