Submission #826705

#TimeUsernameProblemLanguageResultExecution timeMemory
826705ZeroCoolXor Sort (eJOI20_xorsort)C++14
25 / 100
864 ms18364 KiB
#include <bits/stdc++.h> #define int long long #define ll long long #define ld long double using namespace std; const int mxn = 1005; const int SQRT = 500; const int inf = 1e18; const int mod = 998244353; const ld eps = 1e-9; vector<pair<int,int> > res; int A[mxn]; void xswap(int a,int b){ res.push_back({b,a}); res.push_back({a,b}); res.push_back({b,a}); swap(A[a], A[b]); } void solve(int T){ int n,s; cin>>n>>s; for(int i = 0;i<n;i++)cin>>A[i]; while(2 + 2 == 4){ bool found = false; for(int i = 0;i<n-1;i++){ if(s == 1){ if(A[i] >= A[i+1]){ xswap(i, i+1); found = true; } }else{ if(A[i] > A[i+1]){ xswap(i, i+1); found = true; } } } if(!found)break; } cout<<res.size()<<endl; for(auto p: res){ cout<<p.first+1<<" "<<p.second+1<<endl; } } int32_t main(){ #ifdef ONLINE_JUDGE ios::sync_with_stdio(false); cin.tie(0); #endif int t = 1; //cin>>t; for(int i = 1;i<=t;i++)solve(i); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...