Advertisement
NgJaBach

Swapity Swap

Jan 24th, 2023
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. // NgJaBach: Forever Meadow <3
  2.  
  3. #include<bits/stdc++.h>
  4.  
  5. using namespace std;
  6. typedef long long int ll;
  7. typedef unsigned long long ull;
  8. #define pb push_back
  9. #define pob pop_back
  10. #define mp make_pair
  11. #define upb upper_bound
  12. #define lwb lower_bound
  13. #define bend(a) a.begin(),a.end()
  14. #define rev(x) reverse(bend(x))
  15. #define mset(a) memset(a, 0, sizeof(a))
  16. #define fi first
  17. #define se second
  18. #define gcd __gcd
  19. #define getl(s) getline(cin, s);
  20. #define setpre(x) fixed << setprecision(x)
  21. #define endl '\n'
  22. const int N=150,M=1000000007;
  23. const ll INF=1e18+7;
  24. vector<int>arr;
  25. vector<vector<int> >collection;
  26. int main(){
  27.     ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
  28.     freopen("swap.in","r",stdin);
  29.     freopen("swap.out","w",stdout);
  30.     int n,m,k,a,b,u,v,bett;
  31.     bool ok;
  32.     cin>>n>>k;
  33.     cin>>a>>b;
  34.     cin>>u>>v;
  35. //    cout<<"0: ";
  36.     for(int i=0;i<=n;++i) arr.pb(i);
  37.     collection.pb(arr);
  38. //  cout<<endl;
  39.     while(true){
  40. //  for(int turns=1;turns<=k;++turns){
  41.         bett=(a+b)/2;
  42.         for(int i=a;i<=bett;++i) swap(arr[i],arr[b-i+a]);
  43.         bett=(u+v)/2;
  44.         for(int i=u;i<=bett;++i) swap(arr[i],arr[v-i+u]);
  45.         if(arr==collection.front()) break;
  46.         collection.pb(arr);
  47. //      cout<<turns<<": ";
  48. //      for(int i=1;i<=n;++i) cout<<arr[i]<<" ";
  49. //      cout<<endl;
  50.     }
  51.     m=collection.size();
  52.     k%=m;
  53.     for(int i=1;i<=n;++i) cout<<collection[k][i]<<endl;
  54.     return 0;
  55. }
  56. /*
  57. ==================================+
  58. INPUT:                            |
  59. ------------------------------    |
  60. 7 30
  61. 2 5
  62. 3 7
  63.  
  64. 10 20
  65. 1 5
  66. 2 8
  67. ------------------------------    |
  68. ==================================+
  69. OUTPUT:                           |
  70. ------------------------------    |
  71.  
  72. ------------------------------    |
  73. ==================================+
  74. */
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement