# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
370815 |
2021-02-24T17:10:47 Z |
sad |
Cat (info1cup19_cat) |
C++14 |
|
1000 ms |
2704 KB |
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define fi first
#define se second
using namespace std;
vector<int>v,vv;int n;
vector<pair<int,int>>w;
int a[1000000];
int main()
{
int t;cin>>t;
while(t--)
{
int n;
cin>>n;int re=0;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)
{
if(a[i]==i)continue;
for(int j=i+1;j<=n;j++)
{
if(a[j]==i)
{
re++;
w.pb({i,j});
swap(a[i],a[j]);
swap(a[n-i+1],a[n+1-j]);break;
}
}
}
for(int i=1;i<=n;i++)if(a[i]!=i)re=-1;
if(re==-1)
{
cout<<-1<<endl;w.clear();continue;
}
cout<<0<<" "<<w.size()<<endl;
for(auto it:w)
if(it.fi==it.se)continue;
else cout<<it.fi<<" "<<it.se<<endl;
w.clear();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
364 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
620 KB |
Output is correct |
2 |
Correct |
139 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
364 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
620 KB |
Output is correct |
2 |
Correct |
139 ms |
620 KB |
Output is correct |
3 |
Execution timed out |
1095 ms |
2704 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
364 KB |
Wrong answer |