This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define pll pair <ll,ll>
#define F first
#define S second
#define int ll
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
typedef tree <pll,null_type,less <pll>,rb_tree_tag,tree_order_statistics_node_update> orduk;
typedef tree <ll,null_type,less <ll>,rb_tree_tag,tree_order_statistics_node_update> orduk2;
ll n,type;
vector <ll> a;
inline void init() {
cin>>n>>type;
a.resize(n);
for (int i = 0;i < n;i++)
cin>>a[i];
}
vector <pll> ans;
inline void output() {
cout<<ans.size()<<'\n';
for (auto to:ans)
cout<<to.F<<" "<<to.S<<'\n';
exit(0);
}
inline void solve() {
for (int i = 0;i < n;i++)
{
for (int j = i + 1;j < n;j++)
if (a[i] > a[j]) {
ans.pb({j + 1,i + 1});
a[j]^=a[i];
ans.pb({i + 1,j + 1});
a[i]^=a[j];
ans.pb({j + 1,i + 1});
a[j]^=a[i];
}
}
}
int32_t main() {
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
IOS;
int m;
m = 10;
m-=9;
while (m--)
{
init();
solve();
output();
}
}
/*written by Traduttore*/
/*waiting for a miracle...*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |