Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- vector<int> ss(vector<int> &a)
- {
- int n=a.size();
- vector<int> ans(n);
- for(int i=0;i<n-1;i++)
- {
- int minn=*min_element(a.begin()+i,a.end());
- int j;
- for(j=i;j<n-1;j++)
- {
- if(a[j]==minn)
- break;
- }
- swap(a[i],a[j]);
- ans[j+1]=i;
- }
- return ans;
- }
- int main()
- {
- /*int tc;
- cin>>tc;
- vector<vector<int>> ans(tc);
- for(int i=0;i<tc;i++)
- {
- int temp;
- cin>>temp;
- vector<int> v(temp);
- for(int j=0;j<temp;j++)
- {
- int temp2;
- cin>>temp2;
- v[j]+=temp2;
- }
- ans.push_back(iss(v));
- }
- for(auto x:ans){
- for(auto y:x)
- cout<<y<<" ";
- cout<<endl;
- }*/
- vector<int> t=/*{3,2,1},ans;*/{176,-272, -272 ,-45 ,269, -327 ,-945, 176},ans;
- ans=ss(t);
- for(auto x:ans)
- cout<<x<<" ";
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement