-
-
Save veigavitor/28f10131fd8e15efbce7a54f88e5e7ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int32_t main() { | |
ios::sync_with_stdio(false); | |
cin.tie(nullptr); | |
// lemos a entrada | |
int n, p, q, r, s; | |
cin >> n >> p >> q >> r >> s; | |
vector<int> v(n+1); | |
for(int i = 1; i <= n; i++) { | |
cin >> v[i]; | |
} | |
// realizamos a troca dos termos do intervalo pq utilizando o swap | |
for(int i = p; i <= q; i++) { | |
swap(v[i], v[i+(r-p)]); | |
} | |
// printamos o vetor final | |
for(int i = 1; i <= n; i++) { | |
cout << v[i] << " "; | |
} | |
cout << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment