Submission #758326

#TimeUsernameProblemLanguageResultExecution timeMemory
758326ihcekerXor Sort (eJOI20_xorsort)C++14
25 / 100
981 ms18464 KiB
#include<bits/stdc++.h> #define int long long #define MOD 1000000007 #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; int arr[1005]; vector<pair<int,int>>v; void swap2(int a,int b){ v.pb({b,a}); v.pb({a,b}); v.pb({b,a}); swap(arr[a],arr[b]); } int32_t main(){ int n,s; cin>>n>>s; for(int i=1;i<=n;i++){ cin>>arr[i]; } for(int i=1;i<=n;i++){ for(int j=n;j>i;j--){ if(arr[j]<arr[j-1]){ swap2(j-1,j); } } } cout<<v.size()<<endl; for(auto i:v)cout<<i.ff<<" "<<i.ss<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...