Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // NgJaBach: Forever Meadow <3
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef unsigned long long ull;
- #define pb push_back
- #define pob pop_back
- #define mp make_pair
- #define upb upper_bound
- #define lwb lower_bound
- #define bend(a) a.begin(),a.end()
- #define rev(x) reverse(bend(x))
- #define mset(a) memset(a, 0, sizeof(a))
- #define fi first
- #define se second
- #define gcd __gcd
- #define getl(s) getline(cin, s);
- #define setpre(x) fixed << setprecision(x)
- #define endl '\n'
- const int N=150,M=1000000007;
- const ll INF=1e18+7;
- vector<int>arr;
- vector<vector<int> >collection;
- int main(){
- ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
- freopen("swap.in","r",stdin);
- freopen("swap.out","w",stdout);
- int n,m,k,a,b,u,v,bett;
- bool ok;
- cin>>n>>k;
- cin>>a>>b;
- cin>>u>>v;
- // cout<<"0: ";
- for(int i=0;i<=n;++i) arr.pb(i);
- collection.pb(arr);
- // cout<<endl;
- while(true){
- // for(int turns=1;turns<=k;++turns){
- bett=(a+b)/2;
- for(int i=a;i<=bett;++i) swap(arr[i],arr[b-i+a]);
- bett=(u+v)/2;
- for(int i=u;i<=bett;++i) swap(arr[i],arr[v-i+u]);
- if(arr==collection.front()) break;
- collection.pb(arr);
- // cout<<turns<<": ";
- // for(int i=1;i<=n;++i) cout<<arr[i]<<" ";
- // cout<<endl;
- }
- m=collection.size();
- k%=m;
- for(int i=1;i<=n;++i) cout<<collection[k][i]<<endl;
- return 0;
- }
- /*
- ==================================+
- INPUT: |
- ------------------------------ |
- 7 30
- 2 5
- 3 7
- 10 20
- 1 5
- 2 8
- ------------------------------ |
- ==================================+
- OUTPUT: |
- ------------------------------ |
- ------------------------------ |
- ==================================+
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement