fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <set>
  4. #include <fstream>
  5. #include <algorithm>
  6. #include <cctype>
  7. #include <iomanip>
  8. #include <vector>
  9. #include <map>
  10. #include <queue>
  11. #include <numeric>
  12. #include <string>
  13. #include <cmath>
  14. #include <climits>
  15. #include <stack>
  16. #include <complex>
  17. #include <cstdlib>
  18. #include <cstring>
  19. #include <array>
  20. #include <unordered_map>
  21. #include <unordered_set>
  22. #include <functional>
  23. #include <bitset>
  24. #include <cassert>
  25. #include <tuple>
  26.  
  27. using namespace std;
  28. typedef unsigned long long ll;
  29. typedef long double ld;
  30. //int mod = 998244353;
  31. int MOD = 1e9 + 7;
  32.  
  33.  
  34. int main () {
  35. ios_base::sync_with_stdio (false);
  36. cin.tie (NULL);
  37.  
  38. int t = 1;
  39. //cin >> t;
  40. while (t--) {
  41. int n, q;
  42. cin >> n >> q;
  43. vector<int> p (n + 1), pos (n + 1);
  44. iota (p.begin (), p.end (), 0);
  45. pos = p;
  46.  
  47. while (q--) {
  48. char c;
  49. cin >> c;
  50. if (c == 'B') {
  51. int x, y;
  52. cin >> x >> y;
  53. int a = pos[x], b = pos[y];
  54. swap (p[a], p[b]);
  55. pos[x] = b;
  56. pos[y] = a;
  57. } else if (c == 'E') {
  58. int a, b;
  59. cin >> a >> b;
  60. int x = p[a], y = p[b];
  61. swap (pos[x], pos[y]);
  62. p[a] = y;
  63. p[b] = x;
  64. } else {
  65. vector<int> a (n + 1), ans (n + 1);
  66. for (int i = 1 ; i <= n ; i++) {
  67. cin >> a[i];
  68. ans[p[i]] = a[i];
  69. }
  70. for (int i = 1 ; i <= n ; i++) cout << ans[i] << ((i!=n) ? " " : "") ;
  71. if (q) cout << '\n';
  72. }
  73. }
  74. }
  75. return 0;
  76. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty