QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#607 | #404186 | #7902. Strange Sorting | liaoyanxu | liaoyanxu | Success! | 2024-05-03 15:21:23 | 2024-05-03 15:21:23 |
Details
Extra Test:
Runtime Error
input:
1 1 1
output:
result:
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#404186 | #7902. Strange Sorting | liaoyanxu | RE | 5ms | 3640kb | C++23 | 601b | 2024-05-03 15:21:07 | 2024-05-03 15:23:08 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 110
int t,n,a[N];
vector<pair<int,int> > ans;
signed main(){
cin>>t;
while(t--){
ans.clear();
cin>>n;
if(n==1&&a[1]==0) assert(0);
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
if(a[i]!=i){
for(int j=n;j>=i+1;j--){
if(a[i]>a[j]){
ans.push_back(make_pair(i,j));
sort(a+i,a+j+1);
break;
}
}
}
}
cout<<ans.size()<<endl;
for(int i=0;i<ans.size();i++){
cout<<ans[i].first<<' '<<ans[i].second<<endl;
}
}
return 0;
}