# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
861284 | 2023-10-15T19:35:42 Z | Ahmed57 | Cat (info1cup19_cat) | C++17 | 305 ms | 262144 KB |
#include <bits/stdc++.h> using namespace std; vector<pair<int,int>> con; bool vis[200001];int arr[200001]; int main(){ ios_base::sync_with_stdio(false);cin.tie(0); int t;cin>>t; z:while(t--){ int n;cin>>n; for(int i = 1;i<=n;i++)vis[i] = 0; con.clear(); int pos[n+1]; for(int i = 1;i<=n;i++){ cin>>arr[i];pos[arr[i]] = i; } int g = 0;int lol = 0; for(int i = 1;i<=n/2;i++){ if(arr[i]!=i)g++; if(n-arr[i]+1!=arr[n-i+1]){ cout<<-1<<endl; goto z; }if(arr[i]>n/2){ lol++; } } if(lol&1){ cout<<-1<<endl; goto z; } for(int i = 1;i<=n;i++){ while(arr[i]!=i&&arr[n-i+1]!=n-i+1) { int tmp=arr[i]; con.push_back({i,tmp}); swap(arr[i],arr[tmp]); swap(arr[n-i+1],arr[n-tmp+1]); } } cout<<con.size()<<" "<<con.size()<<"\n"; for(auto i:con)cout<<i.first<<" "<<i.second<<"\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 207 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 600 KB | Output is correct |
2 | Correct | 15 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 207 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 600 KB | Output is correct |
2 | Correct | 15 ms | 604 KB | Output is correct |
3 | Correct | 288 ms | 10452 KB | Output is correct |
4 | Correct | 274 ms | 10040 KB | Output is correct |
5 | Correct | 305 ms | 12556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 207 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |