KarleFKremen

Untitled

Jun 23rd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define FILE ""
  3. #define USE_FREOPEN 0
  4. #define USE_LONG 1
  5. #define USE_IOSOPT 0
  6. #if USE_LONG
  7. typedef long long ll;
  8. typedef unsigned long long ull;
  9. #else
  10. typedef int ll;
  11. typedef unsigned int ull;
  12. #endif
  13. #define pb push_back
  14. #define mp make_pair
  15. #define fi first
  16. #define se second
  17. #define ins insert
  18. #define rm erase
  19. #define rs resize
  20. #define sz size
  21. #define hmap unordered_map
  22. #define hset unordered_set
  23. #define p(a, b) pair < a, b >
  24. #define sq(x) ((x) * (x))
  25. #define elsif(x) else if(x)
  26. #define skip(x) if(x) continue;
  27. #define unless(t) if(!(t))
  28. #define rpunless(t) while(!(t))
  29. #define rev(a) reverse(a.begin(), a.end())
  30. #define ord(a) sort(a.begin(), a.end())
  31. #define stlprint(a) \
  32. { \
  33. for(auto __LEVEL_1_STL_ITERATOR = a.begin(); __LEVEL_1_STL_ITERATOR != a.end(); __LEVEL_1_STL_ITERATOR++) \
  34. { \
  35. cout << (*__LEVEL_1_STL_ITERATOR) << ' '; \
  36. } \
  37. cout << endl; \
  38. }
  39. #define die(a) \
  40. { \
  41. cout << a << endl; \
  42. exit(0); \
  43. }
  44.  
  45. using namespace std;
  46.  
  47. void sortarr(vector < ll > &a, ll s, ll n)
  48. {
  49. if(s >= n)
  50. return;
  51. ll minx = s;
  52. for(int i = s; i < n; i++)
  53. {
  54. if(a[minx] > a[i])
  55. minx = i;
  56. }
  57. for(int i = minx; i > s; i--)
  58. {
  59. cout << i << ' ' << (i + 1) << endl;
  60. }
  61. swap(a[s], a[minx]);
  62. sortarr(a, s + 1, n);
  63. }
  64.  
  65. int main()
  66. {
  67. #if USE_IOSOPT
  68. ios_base::sync_with_stdio(false);
  69. cin.tie(0);
  70. #endif
  71. #if USE_FREOPEN
  72. freopen(FILE".in", "r", stdin);
  73. #endif
  74. freopen(FILE"S.out", "w", stdout);
  75. ll n;
  76. cin >> n;
  77. vector < ll > a;
  78. for(int i = 0; i < n; i++)
  79. {
  80. ll d;
  81. cin >> d;
  82. a.pb(d);
  83. }
  84. sortarr(a, 0, a.sz());
  85. }
Advertisement
Add Comment
Please, Sign In to add comment