Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- int main()
- {
- _test
- {
- int n, k;
- cin>>n>>k;
- vector<int> a(n);
- for(auto &e: a)
- cin>>e;
- set<int> st;
- for(int i=0; i<=n; i++)
- st.insert(i);
- for(auto e: a)
- st.erase(e);
- a.push_back(*st.begin());
- int s = (n+1 - k%(n+1))%(n+1);
- for(int i=0; i<n; i++)
- {
- cout<<a[s]<<" ";
- (s += 1) %= (n+1);
- }
- cout<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment