# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
861281 | 2023-10-15T19:28:15 Z | Ahmed57 | Cat (info1cup19_cat) | C++17 | 352 ms | 15340 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 it = 0;it<10;it++){ for(int i = 1;i<=n;i++){ if(arr[i]!=i){ con.push_back({arr[i],i}); swap(arr[i],arr[arr[i]]); swap(arr[n-i+1],arr[arr[n-i+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 | Correct | 4 ms | 348 KB | Correct number of moves |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 860 KB | Output is correct |
2 | Correct | 14 ms | 600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 348 KB | Correct number of moves |
2 | Correct | 16 ms | 860 KB | Output is correct |
3 | Correct | 14 ms | 600 KB | Output is correct |
4 | Correct | 16 ms | 856 KB | Correct number of moves |
5 | Correct | 6 ms | 344 KB | Correct number of moves |
6 | Correct | 5 ms | 348 KB | Correct number of moves |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 860 KB | Output is correct |
2 | Correct | 14 ms | 600 KB | Output is correct |
3 | Correct | 306 ms | 13352 KB | Output is correct |
4 | Correct | 319 ms | 12280 KB | Output is correct |
5 | Correct | 313 ms | 15340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 348 KB | Correct number of moves |
2 | Correct | 16 ms | 860 KB | Output is correct |
3 | Correct | 14 ms | 600 KB | Output is correct |
4 | Correct | 16 ms | 856 KB | Correct number of moves |
5 | Correct | 6 ms | 344 KB | Correct number of moves |
6 | Correct | 5 ms | 348 KB | Correct number of moves |
7 | Correct | 306 ms | 13352 KB | Output is correct |
8 | Correct | 319 ms | 12280 KB | Output is correct |
9 | Correct | 313 ms | 15340 KB | Output is correct |
10 | Correct | 352 ms | 12044 KB | Correct number of moves |
11 | Correct | 269 ms | 9704 KB | Correct number of moves |
12 | Correct | 286 ms | 13264 KB | Correct number of moves |
13 | Correct | 315 ms | 14900 KB | Correct number of moves |
14 | Correct | 286 ms | 13012 KB | Correct number of moves |