#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 |
1 |
Incorrect |
0 ms |
344 KB |
Not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |