solution #include <iostream> #include <algorithm> using namespace std; const int N = 55, M = 1000010; int a[N], b[M], c[N]; void solve(int x, int y) { swap(a[x], a[y]); } int main() { for (int i = 1; i < N; i++) a[i] = i; int n; cin >> n; int x; int idx = 1; for (int i = 1; i < N; i++) { cin >> x; b[idx] = x; idx++; } for (int i = 0; i < n; i++) { for (int j = 1; j < N; j++) { c[j] = a[j]; } for (int k = 1; k < N; k++) { a[b[k]] = c[k]; } } for (int i = 1; i < N; i++) { if (i != 1) cout << " "; int x = a[i]; x -= 1; int t = x / 13; if (t == 0) cout << "S"; else if (t == 1) cout << "H"; else if (t == 2) cout << "C"; else if (t == 3) cout << "D"; else if (t == 4) cout << "J"; cout << (x) % 13 + 1; } }