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>
using namespace std;
const int nx=2e3+5;
int s, n, a[nx];
vector<int> res;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>s;
for (int i=1; i<=n; i++) cin>>a[i];
if (s==1)
{
for (int i=1; i<=n; i++)
{
for (int j=1; j<n; j++)
{
if (a[j]>a[j+1])
{
res.push_back(j);
swap(a[j], a[j+1]);
}
}
}
cout<<res.size()<<'\n';
for (auto x:res)
{
cout<<x<<' '<<x+1<<'\n';
cout<<x+1<<' '<<x<<'\n';
cout<<x<<' '<<x+1<<'\n';
}
}
else
{
return 0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |