Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int n,m;
- int main()
- {
- cin>>n>>m;
- vector<int> arr(m);
- vector<int> perm(n);
- for(int i=0;i<m;i++){cin>>arr[i];arr[i]--;}
- for(int i=0;i<n;i++)
- {
- int cur = i;
- for(int j=0;j<m;j++)
- {
- // move to the right
- if(arr[j]==cur) cur++;
- // move to the left
- else if(arr[j]==cur-1) cur--;
- }
- perm[cur] = i;
- }
- for(int e:perm) cout << e+1 << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment