#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,t,tes,f[200009],boo,pi,k[200009];
pair <int, int> p[3000009];
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>tes;
for(t=1; t<=tes; t++){
cin>>a;
for(i=1; i<=a; i++) cin>>f[i];
boo=0;
for(i=1; i<=a/2; i++){
if(f[i]>a/2){
boo=1;
break;
}
}
if(boo==0){
/*boo=0;
for(i=1; i<=a/2; i++){
if(f[a-i+1]-f[i]!=a/2){
boo=1;
break;
}
}
if(boo==1){
cout<<-1<<endl;
continue;
}*/
pi=0;
for(i=1; i<=a/2; i++){
k[f[i]]=i;
}
for(i=1; i<=a/2; i++){
if(k[i]==i) continue;
pi++;
p[pi].first=k[i];
p[pi].second=i;
c=k[i];d=i;
swap(k[i],k[f[i]]);
swap(f[c],f[d]);
}
for(i=1; i<=pi; i++){
swap(f[a-p[i].first+1],f[a-p[i].second+1]);
}
boo=0;
for(i=2; i<=a; i++){
if(f[i]<f[i-1]){
boo=1;
break;
}
}
if(boo==1){
cout<<-1<<endl;
continue;
}
cout<<pi<<" "<<pi<<endl;
for(i=1; i<=pi; i++){
cout<<p[i].first<<" "<<p[i].second<<endl;
}
continue;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
364 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
1152 KB |
Output is correct |
2 |
Correct |
115 ms |
1132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
364 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
1152 KB |
Output is correct |
2 |
Correct |
115 ms |
1132 KB |
Output is correct |
3 |
Execution timed out |
1089 ms |
12000 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
364 KB |
Wrong answer |