Submission #579899

#TimeUsernameProblemLanguageResultExecution timeMemory
579899Mr_HusanboyXor Sort (eJOI20_xorsort)C++14
25 / 100
119 ms12468 KiB
// Muallif: Mansuraliyev Husanboy Murotali o'g'li >> NamPS #include<bits/stdc++.h> using namespace std; #define ll long long #define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define all(a) a.begin(), a.end() #define F first #define S second // 0-9 >> 48-57; A-Z>>65-90 and a-z>>97-122 respectively; void solve(){ int n,s; cin>>n>>s; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; vector<pair<int,int>> ans; for(int i=1;i<n;i++){ for(int j=0;j<n-i;j++){ if(a[j]>a[j+1]){ ans.push_back({j,j+1}); ans.push_back({j+1,j}); ans.push_back({j,j+1}); swap(a[j+1],a[j]); } } } cout<<ans.size()<<"\n"; for(auto u:ans){ cout<<u.F+1<<' '<<u.S+1<<"\n"; } } int main(){ ios; //int t=1; cin>>t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...