# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
950192 |
2024-03-20T06:43:09 Z |
pcc |
Cat (info1cup19_cat) |
C++17 |
|
8 ms |
2904 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 3e6+10;
int N;
int arr[mxn],pos[mxn];
void change(int a,int b){
swap(pos[arr[a]],pos[arr[b]]);
swap(arr[a],arr[b]);
a = N-a+1,b = N-b+1;
swap(pos[arr[a]],pos[arr[b]]);
swap(arr[a],arr[b]);
return;
}
void solve(){
cin>>N;
for(int i = 1;i<=N;i++)cin>>arr[i],pos[arr[i]] = i;
vector<pii> ans;
for(int i = 1;i<=N;i++){
if(pos[arr[i]] = i)continue;
int a = i,b = pos[arr[i]];
change(a,b);
}
for(int i = 1;i<=N;i++){
if(arr[i] != i){
cout<<"-1\n";
return;
}
}
cout<<ans.size()<<' '<<ans.size()<<'\n';
for(auto &i:ans)cout<<i.fs<<' '<<i.sc<<'\n';
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--)solve();
}
Compilation message
cat.cpp: In function 'void solve()':
cat.cpp:30:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
30 | if(pos[arr[i]] = i)continue;
| ~~~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2392 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
2904 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2392 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
2904 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2392 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |