# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
397277 | 2021-05-01T19:31:57 Z | Pichon5 | Xor Sort (eJOI20_xorsort) | C++17 | 0 ms | 0 KB |
#include <iostream> #include <bits/stdc++.h> #define vi vector<int> #define pb push_back #define F first #define S second #define ll long long #define vll vector<ll> using namespace std; int main() { int x,n,s; cin>>n>>s; vi v; vector<pair<int,int> >E; for(int i=0;i<n;i++){ cin>>x; v.pb(x); } for(int i=0;i<n;i++){ for(int l=0;l<n-1;l++){ if(v[l]>v[l+1]){ E.pb({l+1,l+2});E.pb({l+2,l+1});E.pb({l+1,l+2}); swap(v[l],v[l+1]); } } cout<<E.size()<<endl; for(int i=0;i<E.size();i++){ cout<<E[i].F<<" "<<E[i].S<<endl; } return 0; }